android - Batch contextual action mode -


i want enable multiple view selection on longclick(). should declare action mode object , call startactionmode()? also, how change menu list single item click? used documentation reference, shown.

    listview listview = getlistview();     listview.setchoicemode(listview.choice_mode_multiple_modal);     listview.setmultichoicemodelistener(new multichoicemodelistener() {  @override public void onitemcheckedstatechanged(actionmode mode, int position,                                       long id, boolean checked) {     // here can when items selected/de-selected,     // such update title in cab }  @override public boolean onactionitemclicked(actionmode mode, menuitem item) {     // respond clicks on actions in cab     switch (item.getitemid()) {         case r.id.menu_delete:             deleteselecteditems();             mode.finish(); // action picked, close cab             return true;         default:             return false;     } }  @override public boolean oncreateactionmode(actionmode mode, menu menu) {     // inflate menu cab     menuinflater inflater = mode.getmenuinflater();     inflater.inflate(r.menu.context, menu);     return true; }  @override public void ondestroyactionmode(actionmode mode) {     // here can make necessary updates activity when     // cab removed. default, selected items deselected/unchecked. }  @override public boolean onprepareactionmode(actionmode mode, menu menu) {     // here can perform updates cab due     // invalidate() request     return false; } 

});

to change menu list single item click following code.

int count=0; @override public void onitemcheckedstatechanged(actionmode mode, int position,                                   long id, boolean checked) { if (checked) {             count++;         } else {             count--;         } mode.invalidate();  // add invalidate cab calls onprepareactionmode } 

now modify onprepareactionmode follows

@override public boolean onprepareactionmode(actionmode mode, menu menu) { if (selcount == 1){    //show menu here want if 1 item selected } else {   //show menu here want if more 1 item selected        } } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -