我已经实现SwipeRefreshLayout了我的应用程序,但它只能容纳一个应该是listview的直接子项.我试图找出如何将空文本视图添加到以下工作XML文件:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/listViewConversation"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight="1dp" />
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)
将其包装在线性/相对布局中会使其失灵,因为当您想要向下滑动列表视图时,列表视图将始终更新.我能想到的一种方法是以编程方式进行此操作,但我想这不是最好的选择.
您可以使用本教程学习如何实现它:滑动以刷新GUIDE
所以基本上它一切正常,但我想添加一个空视图,当listview为空时显示一条消息.
为listview设置空视图后,SwipeRefresh无效,这是SwipeRefresh布局的唯一子项.如何解决这个问题?