I load the data from the server in batches. New portions are loaded when scrolling the screen. I AsyncTask
using AsyncTask
.
During loading, a progressBar
and TextView "loaading.."
appear at the bottom of the screen TextView "loaading.."
I wanted to handle the situation when it is impossible to load the data - in this case, the message " failed to load data
" should appear below and the " try again
" button should appear.
Here is the layout
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <!-- Список --> <ListView android:id=" @android :id/list" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_weight="1" android:background="#ffffffff" /> <!-- Панель для прогресс-бара и для проверки подгрузки данных--> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" android:background="#ffffffff" android:orientation="horizontal" > <ProgressBar android:id="@+id/progress_bar" style="?android:attr/progressBarStyleLarge" android:layout_width="42dip" android:layout_height="42dip" /> <TextView android:id="@+id/progress_bar_text" android:layout_width="fill_parent" android:layout_marginLeft="15dip" android:gravity="center_vertical" android:layout_height="wrap_content"/> <Button android:id="@+id/try_again_button" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Try again"> </Button> </LinearLayout> </LinearLayout>
How to implement alternation of progressBar
and buttons for reloading?