johannilsson / android-actionbar

DEPRECATED Android Action Bar Implementation
1.31k stars 564 forks source link

Crash when removing while no action availabe #67

Open jiahaoliuliu opened 12 years ago

jiahaoliuliu commented 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;