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.

verwenden Sie die Symbolleiste als ein action-bar nicht aufblasen Menü

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