【发布时间】:2020-02-22 17:23:25
【问题描述】:
我在实现刷新布局时遇到问题。它涵盖了一切。 我不知道是什么问题,但我尝试从片段更改为活动,没有帮助
这是我的代码:
<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>
另外,我确实认为工具栏有问题,而是放置了一个操作栏(没有帮助)
更新:
这是我的 swiperefresh 布局的功能,以防万一:
@Override
public void onRefresh() {
LoadJson("");
}
private void OnLoadingSwipeRefresh(final String keyword){
swipeRefreshLayout.post(
new Runnable() {
@Override
public void run() {
LoadJson(keyword);
}
}
);
}
【问题讨论】:
标签: java android xml android-recyclerview swiperefreshlayout