Skip to content

Instantly share code, notes, and snippets.

@MeilCli
Last active December 23, 2015 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MeilCli/6656646 to your computer and use it in GitHub Desktop.
Save MeilCli/6656646 to your computer and use it in GitHub Desktop.
Android ActionMode カスタマイズするサンプル
public class ActionModeTest{
public Activity Activity; // 好きなタイミングでset
private ActionMode AB;
public void show(){
if(AB==null&&Activity!=null){
AB = Activity.startActionMode(ActionModeCallback);
}
}
public void close(){
if(AB!=null){
AB.finish();
}
}
private ActionMode.Callback ActionModeCallback = new ActionMode.Callback(){
@Override
public boolean onCreateActionMode(ActionMode mode,Menu menu){
/*
* ここでメニューを作る
*/
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode,Menu menu){
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode,MenuItem item){
/*
* ここで何らかの処理
* return true;
*/
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode){
AB = null;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment