我正在使用SwipeRefreshLayout嵌套RecyclerView,当我开始滑动以删除我的RecyclerView项时,它会触发下拉刷新。我想要在开始滑动时禁用下拉刷新,并在完成滑动时启用它。我使用了ItemTouchHelper类来检测滑动操作。
这是我的.xml文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
你好,这是一个Java文件,
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
}
}).attachToRecyclerView(recyclerView);
android-studio
标签仅适用于寻求 IDE 本身帮助的问题,不适用于 Android 编程。 - letsintegreat