在列表视图的底部添加进度条

loo*_*nis 6 android listview infinite-scroll progress-bar

我正在创建一个带有无限滚动效果的简单列表视图.当我下载新数据时,我想在列表视图的底部显示一个不确定的进度条(如gmail app).

有2个解决方案

  • 将进度条添加为listview的项目,但我不喜欢这个解决方案
  • 在列表视图的底部添加进度条并显示/隐藏它

它会给出类似的东西

<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>
Run Code Online (Sandbox Code Playgroud)

但是当我的列表长度超过我的屏幕大小时(换句话说,当我必须scoll)时,不会显示进度条.

OWZ*_*WZY 7

请改用yourListView.addFooterView(把你的ProgressBar视图)

  • 将FooterView添加到我的listview后,当我尝试将适配器设置为listView时,我得到了类转换异常? (4认同)