[英]Show spinning circle and text in an empty ListView
I am using a ListView
. 我正在使用ListView
。 When the list is empty the spinning circle is showing which I want. 当列表为空时,旋转的圆圈将显示我想要的圆圈。
But I also want a text above/bellow that circle that displays a message eg. 但是我也想要在圆圈上方/下方的文本,例如显示一条消息。 Loading 载入中
Adding the following only shows the text but not the spinning circle 添加以下内容仅显示文本,但不显示旋转圆圈
<?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>
How can I have both? 我怎么都可以?
Note: Not a ProgressDialog
. 注意:不是ProgressDialog
。 The original ListView spinner + Text 原始的ListView微调器+文本
Update: 更新:
If I add the following after the TextView
the spinner breaks my list: 如果在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。
Just place textview and progressbar in a LinearLayout and the id of layout should be android:empty 只需将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.