android - Swipe Refresh Layout onRefresh working but not displaying refresh indicator -
i've implemented swipe refresh layout onto 1 of list views view not sliding down when swipe , icon not visible. though seems doesn't work, fire off onrefresh listener.
also think worth mentioning i'm using listview on fragment i'm initializing listener in fragment activity displayed below.
swipe refresh xml
<android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <listview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listview" android:layout_gravity="center_horizontal" android:dividerheight="1sp" android:translationz="5dp" android:background="@color/background_gray" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:clickable="true" /> </android.support.v4.widget.swiperefreshlayout>
fragment activity
@override public void onviewcreated(view view, @nullable bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); final swiperefreshlayout mswiperefreshlayout = (swiperefreshlayout) getactivity().findviewbyid(r.id.swipe_refresh_layout); listview lview = (listview) getactivity().findviewbyid(r.id.listview); mswiperefreshlayout.setcolorscheme(android.r.color.holo_blue_bright, android.r.color.holo_green_light, android.r.color.holo_orange_light, android.r.color.holo_red_light); mswiperefreshlayout.setonrefreshlistener(new swiperefreshlayout.onrefreshlistener() { @override public void onrefresh() { mswiperefreshlayout.setrefreshing(true); ((mainactivity) getactivity()).refresh(); new handler().postdelayed(new runnable() { @override public void run() { mswiperefreshlayout.setrefreshing(false); } }, 5000); } }); lview.setonscrolllistener(new abslistview.onscrolllistener() { @override public void onscrollstatechanged(abslistview abslistview, int i) { } @override public void onscroll(abslistview abslistview, int firstvisibleitem, int visibleitemcount, int totalitemcount) { if (firstvisibleitem == 0) mswiperefreshlayout.setenabled(true); else mswiperefreshlayout.setenabled(false); } }); }
i solved it, appears current bug swiperefreshlayout. work when listview wrapped inside framelayout.
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <framelayout android:layout_width="match_parent" android:layout_height="match_parent"> <listview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listview" android:layout_gravity="center_horizontal" android:dividerheight="1sp" android:translationz="5dp" android:background="@color/background_gray" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:clickable="true" /> </framelayout> </android.support.v4.widget.swiperefreshlayout>
Comments
Post a Comment