I have a normal NavigationDrawer with different fragments :
The problem :
The NewsFragment contains a SwipeRefreshLayout. It works great the first time I refresh.
I can change fragment to other Stuff 1 and 2 and Setting. So I come back to NewsFragment.
And now when I refresh, the fragment freezes.
The drawerLayout works correctly (open/close, even the ActionBar Title change) but the main fragment stay at NewsFragment and I can't scroll. But the scollListner works (I have log) but the view doesn"t change.
No refreshView (top of the swipeRefreshLayout), no scroll, no responding button (on focus, onclick) but only visually.
Actually, it's like a Responding Fragment is behind the frozen fragment.
Also I have this error in ADBLog :
SwipeRefreshLayout﹕ Got ACTION_MOVE event but don't have an active pointer id.
Any idea ??
I can post code if you ask.
Ok I found the solution. I post it because it can happen to everybody and that's a little boring (two days to find for me).
First I had this in my XML which contains the SwipeRefreshLayout (a fragment):
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/news_container_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:background="@color/news_background">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/news_list_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:dividerHeight="5dp" />
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/news_progress"
android:visibility="invisible"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
So, to fix the bug, YOU NEED TO JUST HAVE THE RECYCLEVIEW (or listview) IN YOUR SWIPEREFRESHLAYOUT :
So, I Move my progressBar and make the RelativeLayout as the rootView.
Result :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/news_progress"
android:visibility="invisible"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/news_container_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:background="@color/news_background">
<android.support.v7.widget.RecyclerView
android:id="@+id/news_list_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:dividerHeight="5dp" />
</android.support.v4.widget.SwipeRefreshLayout>
I hope it will help someone else later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With