Ich habe die Android-Entwickler Seite auf "Einrichten der App-Leiste" verknüpft here. Das Problem ist, ich kann es nicht richtig machen und der Bildschirm zeigt eine seltsame Werkzeugleiste ohne Überlaufmenü. Ich habe einige andere Antworten gelesen und um zu klären, verwende ich Moto G2 zum Testen. Es enthält keine Optionen auf der Hardware-Seite.Toolbar Zeigt das Überlaufmenü nicht
Mein Code ist wie folgt: 1. MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}}
- activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android.toolbardemo.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
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"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
- AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.toolbardemo">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Die Seite Android Developers erwähnen nichts über ein Menü xml und Sachen zu schaffen, damit ich sollte atleast die Grundeinstellungen Abbildung erscheinen. Hier
ist ein Bild von dem, was ich sehe: No Overflow menu
Excellent setzen! Vielen Dank @Amir_P! Ich habe ungefähr 2,5 Stunden damit verbracht, dieses Überlaufmenü zum Laufen zu bringen! –
Danke! Der offizielle Entwicklerleitfaden ist veraltet. Es sollte aktualisiert werden, um Ihr 'onCreateOptionsMenu (...)' hinzuzufügen. –