Post Reply

[Q] How to dismiss contextual action bar programmatically

OP arpitkh96

4th May 2014, 01:55 PM   |  #1  
arpitkh96's Avatar
OP Senior Member
Flag panipat
Thanks Meter: 384
 
1,098 posts
Join Date:Joined: Feb 2012
More
I am using contextual action bar for lisview check box.I want to dismiss it programmatically to ensure that it is hidden if no check box is selected. [/code]private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
// called when the action mode is created; startActionMode() was called
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// Inflate a menu resource providing context menu items
MenuInflater inflater = mode.getMenuInflater();
// assumes that you have "contexual.xml" menu resources
inflater.inflate(R.menu.contextual, menu);
return true;
}
// the following method is called each time
// the action mode is shown. Always called after
// onCreateActionMode, but
// may be called multiple times if the mode is invalidated.
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false; // Return false if nothing is done
}
// called when the user selects a contextual menu item
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.cut:
getActivity().finish();
// the Action was executed, close the CAB

return true;
default :
return false;
}
}
// called when the user exits the action mode
public void onDestroyActionMode(ActionMode mode) {
mActionMode = null;
checkedindex.clear();
loadlist(new File(prog.getText().toString()));
checkedindex.clear();
selection=false;
}
};

[/Code]
I am using it like this
Code:
mActionMode = getActivity().startActionMode(mActionModeCallback);
Where mActionMode is object(Universal)
I have tried mActionMode=null; or mActionMode.finish() etc.

Sent from my GT-S5570 using XDA Premium 4 mobile app
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Java for Android App Development by ThreadRank