我的应用程序中有CAB菜单。我要求更改" DONE"按钮到"添加"。我怎么能这样做?
我能够看到设计元素。但不是我的要求。
<item name="android:actionModeCloseDrawable"></item>
<item name="android:actionModeCutDrawable"></item>
<item name="android:actionModeCopyDrawable"></item>
<item name="android:actionModePasteDrawable"></item>
<item name="android:actionModeSelectAllDrawable"></item>
<item name="android:actionModeBackground"></item>
<item name="android:actionModeCloseButtonStyle"></item>
答案 0 :(得分:-3)
您可以像其他菜单一样在xml文件中定义它。然后在回调中引用它,如此
private final class ModeCallback implements ActionMode.Callback {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = Activity.getSupportMenuInflater();
inflater.inflate(R.menu.contexual_menu, menu);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
//Destroy something
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
Toast.makeText(Activity.this, "Well done you made an custom CAB", Toast.LENGTH_SHORT).show();
}
};
确保你像这样启动actionMode
startActionMode(new ModeCallback());