[英]How do I delete a default item in the contextual action bar (CAB)?
There are some questions like this already made in Stack Overflow but none of the selected solutions has worked for me. 在Stack Overflow中已经有一些类似的问题,但是没有一个选择的解决方案对我有用。 These links appear to make different choices, but I tried and I could not remove the first option which is by default.
这些链接似乎做出了不同的选择,但是我尝试了并且无法删除默认情况下的第一个选项。
Link 1 Link 2 Link 3 Link 4 链接1 链接2 链接3 链接4
Ignore the item icons. 忽略项目图标。 I need to delete the item in the circle.
我需要删除圈子中的项目。
private class ModoAccion implements ActionMode.Callback {
private ArrayList<Integer> listaOpciones = new ArrayList<Integer>();
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
MenuInflater inflater = actionMode.getMenuInflater();
menu.clear();
inflater.inflate(R.menu.admin_detalle_emp_action_mode, menu);
actionMode.invalidate();
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
listaOpciones.add(R.id.accion_cancelar);
listaOpciones.add(R.id.accion_guardar);
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
if (!listaOpciones.contains(item.getItemId()))
item.setVisible(false);
}
return false;
}
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.accion_cancelar:
actionMode.finish(); // Action picked, so close the CAB
return true;
default:
return false;
}
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
mActionMode = null;
}
}
You can't actually get rid of that area of the context action bar. 您实际上无法摆脱上下文操作栏的该区域。 However, you can change its drawable (even to nothing if you like) by styling your app.
但是,您可以通过设置应用样式来更改其drawable(甚至可以随意更改)。 Just override item name
android:actionModeCloseDrawable
and insert your own drawable. 只需覆盖项目名称
android:actionModeCloseDrawable
并插入您自己的drawable。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.