滑动刷新布局覆盖 recyclerview
SwipeRefresh Layout is covering the recycleview
我在实施刷新布局时遇到问题。它涵盖了一切。
我不知道是什么问题,但我尝试将片段从 activity 更改为 activity,但没有帮助
这是我的代码:
<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>
此外,我确实认为工具栏有问题,所以改用操作栏(没有帮助)
更新:
刷屏刷新布局是我的功能,以防万一:
@Override
public void onRefresh() {
LoadJson("");
}
private void OnLoadingSwipeRefresh(final String keyword){
swipeRefreshLayout.post(
new Runnable() {
@Override
public void run() {
LoadJson(keyword);
}
}
);
}
我发现了我的错误。它不在我的布局中。它在适配器的代码中。
@Override
public int getItemCount() {
return articles.size();
}
return 0;默认设置,这是我的错误。
我知道这很愚蠢,但以防万一像我这样的人跳过该错误并且不知道为什么。
我在实施刷新布局时遇到问题。它涵盖了一切。 我不知道是什么问题,但我尝试将片段从 activity 更改为 activity,但没有帮助
这是我的代码:
<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>
此外,我确实认为工具栏有问题,所以改用操作栏(没有帮助)
更新:
刷屏刷新布局是我的功能,以防万一:
@Override
public void onRefresh() {
LoadJson("");
}
private void OnLoadingSwipeRefresh(final String keyword){
swipeRefreshLayout.post(
new Runnable() {
@Override
public void run() {
LoadJson(keyword);
}
}
);
}
我发现了我的错误。它不在我的布局中。它在适配器的代码中。
@Override
public int getItemCount() {
return articles.size();
}
return 0;默认设置,这是我的错误。 我知道这很愚蠢,但以防万一像我这样的人跳过该错误并且不知道为什么。