【发布时间】:2015-06-13 11:22:09
【问题描述】:
我想要做的是,允许用户滑动和刷新列表,数据是否存在并不重要。但是当列表视图中有数据时,只有列表视图应该是可见的,而当数据不存在时,空文本视图应该是可见的。在这两种情况下,用户都必须能够通过滑动刷新列表。
我尝试了一些解决方案 here in this discussion 但它们听起来都不起作用,采用两个 SwipeToRefresh 的想法可以正常工作,因为给定Here,但即使在从服务器获取数据时它也会显示空容器。
我尝试使用我自己的逻辑将 Listview 和 Textview 包装在 Relative/FrameLayout 中,但 SwipeToRefresh 仅根据其行为接受一个视图
这是我尝试过的 xml sn-p
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.945" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/event_list_eventlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/event_background"
android:dividerHeight="1dp" >
</ListView>
<TextView
android:id="@+id/event_txt_nothing_found"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/darker_gray"
android:visibility="gone" />
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
请帮忙
【问题讨论】:
标签: android android-listview swiperefreshlayout