verwenden Sie die Symbolleiste als ein action-bar nicht aufblasen Menü
Ich versuche, verwenden Sie die Symbolleiste als ein action-bar, und ich Folge den Chris Dämonen-guide:
https://chris.banes.me/2014/10/17/appcompat-v21/
Nun folgenden setup habe ich eine leere Symbolleiste, es scheint, dass die getMenuInflater().inflate() nicht funktioniert.
In meiner Tätigkeit habe ich:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menuhome, menu);
[...]
und in onCreate():
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
Und das ist mein layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:allmytv="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/linearlayoutmain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
xmlns:allmytv="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary" />
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dip"
allmytv:pstsIndicatorColor="#f57c1d" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</android.support.v4.view.ViewPager>
</LinearLayout>
Wo bin ich falsch?
InformationsquelleAutor Giuseppe | 2014-11-12
Schreibe einen Kommentar Antworten abbrechen
Du musst angemeldet sein, um einen Kommentar abzugeben.
Inorder zu verwenden Symbolleiste actionbar, die Sie brauchen, um das Attribut zu setzen windowActionBar als falsch.
Gehören styles.xml
In manifest.xml unter tag mit dem obigen Thema
Habe ich verwendet Symbolleiste aufblasen, um den Menü:
NoActionBar
zum Thema. Man kann beide verwenden eine Symbolleiste und Actionbar durch den AufrufsetSupportActionBar(toolbar);
Das war absolut ein sehr spezifisches Problem.
Das Problem war, dass ich eine splashscreen eingestellt mit :
Symbolleiste leer war, weil ich call setSupportActionBar(toolbar), wenn der splashscreen aktiv war.
Verschieben der setSupportActionBar(Symbolleiste) an der richtigen Stelle fixiert!
setSupportActionBar(toolbar)
sollte ein nicht-null-toolbar...