Wie man eine Schaltfläche in ActionBar (Android) hinzufügt?
Ich möchte der Aktionsleiste auf der rechten Seite des Beispiels eine Schaltfläche hinzufügen, wie in diesem Screenshot gezeigt:
In der onCreate-Methode erhalte ich actionBar als:
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
und Zurück-Schaltfläche (onOptionsItemSelected-Methode) wie folgt:
public boolean onOptionsItemSelected(MenuItem item){
Intent myIntent = new Intent(getApplicationContext(),MainActivity.class);
startActivityForResult(myIntent, 0);
return true;
}
Wie kann ich eine Schaltfläche hinzufügen?