android ListView没有数据时信息显示
16lz
2022-03-25
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"。
更多相关文章
- 如果没有 Android(安卓)世界会是什么样子?
- android学习---通过android帮助学习TextView属性
- android之layout_weight体验(实现按比例显示)
- Android(安卓)使用WebView加载含有echarts的页面,截图不显示的解
- Android图形显示系统(一)
- ant script to obfuscate android code
- 解决TextView设置跑马灯但却没有效果
- android 图片解码显示流程
- Android图形显示系统(一)