通过添加一个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系统的启动
  3. Android系统启动流程
  4. Android 根文件系统分析
  5. Android学习系列(39)--Android主题和样式之系统篇(上)
  6. 从零开始--系统深入学习android(实践-让我们开始写代码-Android框
  7. 经典Android系统源代码

随机推荐

  1. 1.vue常用术语 2. 样式与事件绑定 3. 列
  2. 【视频版】最新版PyCharm 2021.3.3 激活
  3. JS框架 -(一)fetch async await 模块 npm
  4. 实现鼠标悬停时自动停止播放离开时又自动
  5. vue常用术语、样式与事件绑定 和 列表渲
  6. 1. 实例演示fetch api, async,await的使
  7. 从淘宝进货卖到亚马逊,能做到利润可观吗?
  8. 【视频版】Goland 2022.1 最新正版激活方
  9. 【视频版】phpstorm 2021.3.3 最新正版激
  10. android有用的知识