我正在尝试执行删除操作,以便可以从项目中删除一个项目,但是该项目未在应用程序中显示,有人可以帮助我,这是我添加到historyFragment中的代码
ItemTouchHelper helper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0,ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
return 0;
}
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder target, int i) {
int position = target.getAdapterPosition();
mData.remove(position);
newsAdapter.notifyDataSetChanged();
}
});
helper.attachToRecyclerView(NewsRecyclerview);
答案 0 :(得分:0)
您可以尝试删除getMovementFlags重写方法并重试吗?据我了解,它阻止了运动