Last Updated: May 18, 2020
·
3.587K
· jonaldomo

Quick and Dirty Loading Row in Android ListView

res/layout/footer.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:background="#ddd"
        android:gravity="center"
        android:layout_height="wrap_content"
        android:padding="12dp"
        android:baselineAligned="true">
    <ProgressBar
            android:layout_marginRight="8dp"
            android:layout_height="20dp"
            android:layout_width="20dp" />
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Loading..."
            android:textColor="#000" />
</LinearLayout> 

In your ListActivity

View footer = ((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.footer, null, false);
 this.getListView().addFooterView(footer);

I use this for infinitely scrolling lists as seen here:

Picture