android - ItemTouchHelper startSwipe not working -
i tried use startswipe within adapter, seems not working. strangely, when tried swipe finger manually, worked. startswipe not work when clicked on of button inside holder. need on this~
this called startswipe (in oncreateviewholder method).
final viewholder holder = new viewholder(rootview); holder.rightitemlayout.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { mitemtouchhelper.startswipe(holder); } });
this how setup itemtouchhelper:
mitemtouchhelper = new itemtouchhelper(new itemtouchhelper.simplecallback(0, itemtouchhelper.left) { @override public boolean onmove(recyclerview recyclerview, recyclerview.viewholder viewholder, recyclerview.viewholder target) { return true; } @override public void onswiped(recyclerview.viewholder viewholder, int direction) { } });
how itemtouchhelper attached recyclerview:
recyclerview.layoutmanager mlayoutmanager = new linearlayoutmanager(getapplicationcontext()); recyclerview.setlayoutmanager(mlayoutmanager); recyclerview.setitemanimator(new defaultitemanimator()); categoryadapter adapter = new categoryadapter(this, items); recyclerview.setadapter(adapter); adapter.getitemtouchhelper().attachtorecyclerview(recyclerview);
Comments
Post a Comment