Open jiahaoliuliu opened 12 years ago
The example crashes when the user is trying to remove the action bar when no action bar is shown (All them have been removed).
To fix this, when the user is removing, the number of the actions in the action bar should be checked:
case (R.id.remove_action): { int actionCount = actionBar.getActionCount(); if (actionCount > 0) { actionBar.removeActionAt(actionCount - 1); Toast.makeText(HomeActivity.this, "Removed action." , Toast.LENGTH_SHORT).show(); } break;
The example crashes when the user is trying to remove the action bar when no action bar is shown (All them have been removed).
To fix this, when the user is removing, the number of the actions in the action bar should be checked: