AndroidSwipeLayout icon indicating copy to clipboard operation
AndroidSwipeLayout copied to clipboard

how to make single item swipe and other should close automatically

Open ganatrajay opened this issue 8 years ago • 12 comments

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

ganatrajay avatar Apr 13 '16 05:04 ganatrajay

just call method mSwipe.close() in OnClick function

BakytzhanAkzhol avatar Apr 17 '16 16:04 BakytzhanAkzhol

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(); } }

JitenNumberTank avatar Apr 29 '16 09:04 JitenNumberTank

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.

lou78 avatar May 09 '16 08:05 lou78

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 avatar May 15 '16 02:05 azizimusa

@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.

swipe layout

EpariNigam avatar Jun 03 '16 05:06 EpariNigam

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 :)

ZubairKh avatar Oct 13 '17 11:10 ZubairKh

@azizimusa you just saved my day. Thanks !

darrelRayen avatar Dec 06 '17 05:12 darrelRayen

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

saprahits avatar Jan 27 '18 06:01 saprahits

waht is ItemManger?

ajaydhadhal1111 avatar Mar 28 '19 07:03 ajaydhadhal1111

@ajaydhadhal1111

Add this in your adapter SwipeItemRecyclerMangerImpl mItemManger = new SwipeItemRecyclerMangerImpl(this);

Abdallah4021 avatar Oct 13 '19 09:10 Abdallah4021

Please help me, After Swipe right or left, it navigate to other screen depend upon right and left action.

dubeyvivek57 avatar Nov 22 '19 06:11 dubeyvivek57

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 :)

Its worked with library https://github.com/chthai64/SwipeRevealLayout

longquangpham90 avatar Mar 20 '23 10:03 longquangpham90