Add progress to the bottom of the list.

I am creating a simple list with an endless scroll effect. While I'm uploading new data, I want to display vague progress at the bottom of the list (e.g. gmail app).

There are 2 solutions.

  • Add progress progress as an element of my list, but I don't like this solution
  • Add a progress bar at the bottom of the list and show / hide it

It will give something like this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ListView android:id="@+id/List_list" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <ProgressBar android:id="@+id/trobber" android:layout_below="@+id/List_list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:indeterminate="true" > </ProgressBar> </RelativeLayout> 

But the progress indicator does not appear if my list is longer than the size of my screen (in other words, when I have to toss).

+6
source share
2 answers

use yourListView instead. addFooterView (put your ProgressBar view)

+7
source

To clarify how you do this:

a. Create an XML layout file, name it as progress_bar_footer.xml

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ProgressBar android:layout_width="30dip" android:layout_height="30dip" android:layout_gravity="center" android:indeterminateTint="@android:color/holo_green_light" android:id="@+id/progressBar5"/> </LinearLayout> 

B. In your work

 View mProgressBarFooter = ((LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.progress_bar_footer, null, false); 

C. Use this.

 listView.addFooterView(mProgressBarFooter); //or listView.removeFooterView(mProgressBarFooter); 

Credit goes to this John Moses .

+3
source

Source: https://habr.com/ru/post/947246/


All Articles