[英]Repopulate recycleview data on left-right swipe gesture
I am designing a layout in which I have 3 RecycleView
s which is depicted in the picture, the leftmost 'purple' RecycleView
is fixed.我正在设计一个布局,其中我有 3
RecycleView
s,如图所示,最左边的“紫色” RecycleView
是固定的。 The next two RecycleView
s data is changed on swipe.接下来的两个
RecycleView
的数据在滑动时发生了变化。 Kind of like a table, I simply repopulate these RecycleViews
with new List
data.有点像表格,我只是用新的
List
数据重新填充这些RecycleViews
。 Now normally swipe is used in RecycleView
for one item, here I want to add swipe gesture for whole list.现在通常在
RecycleView
为一项使用滑动,这里我想为整个列表添加滑动手势。
This is what I have done, but the swipe is only for one element and for some reasons it doesn't populate RecycleView
.这就是我所做的,但是滑动仅针对一个元素,并且由于某些原因它不会填充
RecycleView
。 however the same method is working for click next button.但是相同的方法适用于单击下一步按钮。 I know this could be done using
ViewPager
but I am still looking if there is some swipe method for RecycleView
which lets me repopulate whole RecycleView
instead of swipe on one single item data.我知道这可以用做
ViewPager
,但我仍然在寻找是否有一些刷卡方法RecycleView
这让我重新填充整个RecycleView
,而不是刷卡就一个单项数据。
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT | ItemTouchHelper.DOWN | ItemTouchHelper.UP) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
Toast.makeText(getApplicationContext(), "on Move", Toast.LENGTH_SHORT).show();
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
Toast.makeText(getApplicationContext(), "on Swiped ", Toast.LENGTH_SHORT).show();
//Remove swiped item from list and notify the RecyclerView
adapterOdds1.updateListOdds(allBestSiteGamesList.get(oddsListDipslay), oddsListDipslay);
}
};
ItemTouchHelper
will not help in this case, since i want to use swipe for whole list, so i found the following solution helpful to implement the desired feature that i wanted without need to use viewpager
.在这种情况下
ItemTouchHelper
将无济于事,因为我想对整个列表使用滑动,所以我发现以下解决方案有助于实现我想要的所需功能,而无需使用viewpager
。
His solution helped solve my problem.他的解决方案帮助解决了我的问题。 https://stackoverflow.com/a/50969707/3952885
https://stackoverflow.com/a/50969707/3952885
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.