[英]Show spinning circle and text in an empty ListView
我正在使用ListView
。 当列表为空时,旋转的圆圈将显示我想要的圆圈。
但是我也想要在圆圈上方/下方的文本,例如显示一条消息。 载入中
添加以下内容仅显示文本,但不显示旋转圆圈
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<TextView android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Loading...."
android:gravity="center"
android:layout_gravity="center"
</LinearLayout>
我怎么都可以?
注意:不是ProgressDialog
。 原始的ListView微调器+文本
更新:
如果在TextView
之后添加以下内容,则微调TextView
将中断我的列表:
<ProgressBar
android:id="@+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2" >
</ProgressBar>
使您的TextView的高度和宽度wrap_content而不是match_parent。
只需将textview和progressbar放在LinearLayout中,布局的ID应该为android:empty
<LinearLayout android:id="@+id/android:empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" > <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Loading..." /> </LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.