我想这样做:当我们从左向右滑动时,它将删除特定视图,当我们从右向左滑动时,它将在视图下显示可点击的按钮。 在这种情况下,当我们从左向右滑动时,它会移除视图,当我们从右向左滑动时,它会显示按钮,但也会移除视图。
@Override
public void onBindViewHolder(final SimpleViewHolder viewHolder, final int position) {
final Student item = studentList.get(position);
viewHolder.tvName.setText((item.getName()));
viewHolder.tvEmailId.setText(item.getEmailId());
viewHolder.swipeLayout.setShowMode(SwipeLayout.ShowMode.PullOut);
// Drag From Left
viewHolder.swipeLayout.addDrag(SwipeLayout.DragEdge.Left, viewHolder.swipeLayout.findViewById(R.id.bottom_wrapper1));
// Drag From Right
viewHolder.swipeLayout.addDrag(SwipeLayout.DragEdge.Right, viewHolder.swipeLayout.findViewById(R.id.bottom_wrapper));
// Handling different events when swiping
viewHolder.swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
@Override
public void onClose(SwipeLayout layout) {
}
@Override
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
}
@Override
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
//when user's hand released
swipeDelte = true;
Log.e("TagX", xvel + "");
Log.e("tagY", yvel + "");
if (swipeDelte == true && yvel <= 0 && xvel <= 0) {
Log.e("Item", "Item in ");
swipeDelte = true;
} else if (yvel >= 0 && xvel != 0 && xvel > 0) {
swipeDelte = true;
Log.e("Item Remove", "item remove");
mItemManger.removeShownLayouts(viewHolder.swipeLayout);
studentList.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, studentList.size());
mItemManger.closeAllItems();
// }
}