Android SwipeRefreshLayout with empty TextView not working properly -
what want , allow user swipe , refresh list, not matter if data there or not. when data there in listview listview should visible, , when data not there , empty textview should visible. in both cases user must able refresh list swipe.
i tried solution given here in discussion none of them sounds working, idea of taking 2 swipetorefresh works fine given here, shows empty container while fetching data server.
i tried own logic wrapping listview , textview inside relative/framelayout swipetorefresh accepts 1 view per behavior
here xml snippet have tried
<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>
please help
i solved same problem using framelayout, @ below code:
<framelayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.widget.swiperefreshlayout android:id="@+id/layout_swipe_refresh" android:layout_width="match_parent" android:layout_height="wrap_content"> <listview android:id="@+id/lv_products" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="@null" /> </android.support.v4.widget.swiperefreshlayout> <textview android:id="@+id/tv_no_product" style="@android:style/textappearance.medium" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="10dp" android:gravity="center" android:text="@string/msg_no_listing" android:textcolor="@color/primary_green" android:visibility="gone" /> </framelayout>
you use relativelayout well, key placing listview inside swiperefreshlayout, , textview outside.
Comments
Post a Comment