I am using a 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
. The original ListView spinner + Text
Update:
If I add the following after the TextView
the spinner breaks my list:
<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
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.