java - GridView CAB not showing up on Long click -
gridview = (expandablegridview)findviewbyid(r.id.grid); gridview.setchoicemode(expandablegridview.choice_mode_multiple_modal); gridview.setmultichoicemodelistener(new expandablegridview.multichoicemodelistener() { @override public void onitemcheckedstatechanged(actionmode mode, int position, long id, boolean checked) { if(checked) { checkeditems.add(position); } else { checkeditems.remove(checkeditems.indexof(position)); } int checkedcount = gridview.getcheckeditemcount(); mode.settitle(checkedcount + " selected"); } @override public boolean oncreateactionmode(actionmode mode, menu menu) { log.i("test", "oncreateactionmode"); menuinflater inflater = mode.getmenuinflater(); inflater.inflate(r.menu.menu_main, menu); menu.finditem(r.id.done).setvisible(false); return true; } @override public boolean onprepareactionmode(actionmode mode, menu menu) { menu.finditem(r.id.done).setvisible(true); return true; } @override public boolean onactionitemclicked(actionmode mode, menuitem item) { switch (item.getitemid()) { case r.id.done: toast.maketext(mainactivity.this, "sent", toast.length_long).show(); mode.finish(); return true; default: return false; } } @override public void ondestroyactionmode(actionmode mode) { checkeditems.removeall(checkeditems); } }); gridview.setonitemlongclicklistener(new adapterview.onitemlongclicklistener() { @override public boolean onitemlongclick(adapterview<?> parent, view view, int position, long id) { gridview.setitemchecked(position,!checkeditems.contains(position)); return true; } });
i trying pick multiple images store in other place. tried gridview
, expandablegridview
oncreateactionmode
never called. callback methods onitemclick
, onitemlongclick
not working.
working fine if handling onclick
through adapter class. please if missing something.
gridview
starts actionmode
long clicking on 1 of it's items default. so, try remove custom onitemlongclicklistener
, see, if works.
Comments
Post a Comment