AndroidSwipeLayout
AndroidSwipeLayout copied to clipboard
how to make single item swipe and other should close automatically
hi,
please help me out for like if swipe one item in recyclerview , other item of list should swipe close automatically , at a time single item should open
just call method mSwipe.close() in OnClick function
Hello Bakytzhan Akzhoi I am also closing layout as below code. but still I am not getting close layout. I am use this method as
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
if (swipeLayout != null) { swipeLayout.close(); } }
In your OnBindViewHolder() method,add one line mItemManger.bindView(holder.itemView,position)
; It might be mItemManger,bind()
based on the library version. It works for me.
yes @lou78 is right. It solve my case.
// inside OnBindViewHolder() method, at the very bottom. put this code ItemManger.bindView(holder.itemView, position);
// and then add swipelistener to current swipelayout holder.swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() { @Override public void onStartOpen(SwipeLayout layout) { mItemManger.closeAllExcept(layout); } }
that will automatically close others opened swipelayout and open the current layout seamlessly.
@azizimusa As you said, i implemented this. I am facing jerk with the behind layouts. Please find the attached image for that. Here the button left is behind layout. and on swipe it's coming above the main surface view.
Below code worked for me
Initialize ViewBinderHelper binderHelper = new ViewBinderHelper();
Then, in your onBindViewHolder
method right below binderHelper.bind(...);
use binderHelper.setOpenOnlyOne(true);
This will automatically close already opened when swipe for new one
:)
@azizimusa you just saved my day. Thanks !
how to make single item swipe and other should close automatically `public class EventListAdapter extends RecyclerSwipeAdapter<EventListAdapter.MyViewHolder> implements Filterable { private SwipeLayout preswipes=null;
@Override public int getSwipeLayoutResourceId(int position) { return R.id.swipe; }
public class MyViewHolder extends RecyclerView.ViewHolder { private SwipeLayout swipes;
public MyViewHolder(View itemView) {
swipes = (SwipeLayout) itemView.findViewById(R.id.swipe);
swipes.setClickToClose(true);
swipes.addSwipeListener(new SwipeLayout.SwipeListener() {
@Override
public void onStartOpen(SwipeLayout layout) {
if(preswipes==null) {
preswipes=layout;
}else
{
preswipes.close(true);
preswipes=layout;
}
}
@Override
public void onOpen(SwipeLayout layout) {
}
@Override
public void onStartClose(SwipeLayout layout) {
}
@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) {
}
});
} `
It's Work Code Try is www.patelwala.com
waht is ItemManger?
@ajaydhadhal1111
Add this in your adapter SwipeItemRecyclerMangerImpl mItemManger = new SwipeItemRecyclerMangerImpl(this);
Please help me, After Swipe right or left, it navigate to other screen depend upon right and left action.
Below code worked for me Initialize
ViewBinderHelper binderHelper = new ViewBinderHelper();
Then, in youronBindViewHolder
method right belowbinderHelper.bind(...);
usebinderHelper.setOpenOnlyOne(true);
This will automatically close already opened when swipe for new one :)
Its worked with library https://github.com/chthai64/SwipeRevealLayout