android ListView没有数据时信息显示

文章分类:JavaEye

通过添加一个id为android:empty的TextView,当ListView里面没有data的时候,就会显示TextView的内容。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="对不起,没有数据显示"/>
</LinearLayout>

需要注意的是,ListView的id,使用的是"@id/android:list",即系统默认的id,而紧接其后的TextView,使用的id也是系统默认的,即"@id/android:empty"。

更多相关文章

  1. 如果没有 Android(安卓)世界会是什么样子?
  2. android学习---通过android帮助学习TextView属性
  3. android之layout_weight体验(实现按比例显示)
  4. Android(安卓)使用WebView加载含有echarts的页面,截图不显示的解
  5. Android图形显示系统(一)
  6. ant script to obfuscate android code
  7. 解决TextView设置跑马灯但却没有效果
  8. android 图片解码显示流程
  9. Android图形显示系统(一)

随机推荐

  1. 【Android】事件分发机制
  2. Android GPS学习笔记—LMS初始化
  3. Android开关机动画制作
  4. android中gps的使用以及解析nmea0183协议
  5. android 在调用执行了reboot系统层做部分
  6. 系出名门Android(7) - 控件(View)之ZoomC
  7. Android 相机拓展库,能够实时采集并且识别
  8. android中使用DisplayMetrics获取屏幕参
  9. Android keystore 调试
  10. Android仿微信QQ群头像生成