Ich folgte dieser Anleitung (https://developer.android.com/training/appbar/setting-up.html), um eine Aktionsleiste für meine Aktivität einzurichten, aber ich kann die Menüschaltfläche (3 horizontale Zeilen oben rechts) nicht anzeigen.Menü wird nicht in der Symbolleiste angezeigt
Ich erweitere AppCompatActivity und verwende ein GoogleMap-Fragment, das korrekt unter meiner Aktionsleiste angezeigt wird.
Im Manifest habe ich eingestellt:
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
wie sie in der Anleitung beschrieben.
Menü Ressourcendatei
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_settings"
android:title="@string/action_settings"
app:showAsAction="always" />
</menu>
Toolbar xml
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:title="@string/toolbar_title"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(LOG_TAG, "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
//Toolbar
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
myToolbar.inflateMenu(R.menu.menu_activity_maps);
setSupportActionBar(myToolbar);
getSupportActionBar().setTitle("yoyo");
//Obtain the SupportMapFragment and call onMapReady when it is ready to be used
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
Wie erhalte ich th Das Menü zu zeigen?