There are some questions like this already made in Stack Overflow but none of the selected solutions has worked for me. These links appear to make different choices, but I tried and I could not remove the first option which is by default.
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. Just override item name android:actionModeCloseDrawable
and insert your own drawable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.