Vivek Pratap Singh Vivek Pratap Singh - 12 days ago 5
Android Question

swipe to refresh not working with list and grid on the same screen


i am using recycler view for list and grid on the same screen but swipe to refresh not working


<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="wrap_content">

<android.support.v7.widget.RecyclerView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

</android.support.v7.widget.RecyclerView>

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />





any suggestions where i am doing wrong or Am i implementing in a wrong way?

Answer

this is what worked for me

<android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/list_refresh"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/trending_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="visible" />

    </android.support.v4.widget.SwipeRefreshLayout>


        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/grid_refresh"
            android:visibility="gone"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/trending_grid"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone" />

        </android.support.v4.widget.SwipeRefreshLayout>

multiple recycler views do not work with same swipe to refresh

as swipe to refresh can contain only one child

`

Comments