java – SwipeRefresh Layout is covering the recycleview-ThrowExceptions

Exception or error:

I have a problem with implementing a refresh layout. It is covering everything.
I don’t know what is the problem, but I tried changing from fragment just to activity, didn’t help

here is my code:

<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:background="@color/background">




      <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background">

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/topheadelines"
                    android:textColor="@color/colorTextTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:text="Top Headlines"
                    android:fontFamily="sans-serif-light"
                    android:textSize="17sp"
                    android:layout_marginLeft="16dp"
                    android:layout_marginRight="16dp"
                    android:layout_marginTop="10dp"
                    android:visibility="invisible"/>

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/recyclerView"
                    android:scrollbars="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                  </androidx.recyclerview.widget.RecyclerView>

               </LinearLayout>

           </androidx.core.widget.NestedScrollView>

        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
   </androidx.coordinatorlayout.widget.CoordinatorLayout>

Also, I did think that there was a problem with a toolbar and put an actionbar instead( didn’t help)

UPDATE:

It is my function for the swiperefresh layout, just in case:

@Override
    public void onRefresh() {
        LoadJson("");
    }

    private void OnLoadingSwipeRefresh(final String keyword){

        swipeRefreshLayout.post(
                new Runnable() {
                    @Override
                    public void run() {
                        LoadJson(keyword);
                    }
                }

        );
    }
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *