2017-01-21 1 views
0

Ich habe versucht, Bild in meiner App-Leiste/Symbolleiste zu platzieren, aber es funktioniert nicht. Ich habe diese Abfrage über diese Website durchsucht, aber keine zufriedenstellende Antwort erhalten.Symbolleiste/aapbar Bild

Meine minimun SDK-Version ist 15 und Ziel-SDK ist 24.Really dankbar, wenn jemand meine Frage beantwortet

Das ist mein menu_main Code

<?xml version="1.0" encoding="utf-8"?> 
    <menu xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:aap="http://schemas.android.com/apk/res-auto" 
     xmlns:app="http://schemas.android.com/tools"> 
     <item 
      android:id="@+id/sett" 
      android:title="@string/set" 
      android:orderInCategory="100" 
      app:showAsAction="never"/> 
     <item android:id="@+id/nav" 
      android:title="@string/butt" 
      android:orderInCategory="200" 
      android:icon="@drawable/ic_keyboard_arrow_right_black_24dp" 
      aap:showAsAction="always"/> 
    </menu> 

enter image description here Das ist mein aap bar xml file

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    xmlns:aap="http://schemas.android.com/apk/res-auto" 
    android:background="#C6FF00" 
    aap:popupTheme="@style/ThemeOverlay.AppCompat.Dark"> 
</android.support.v7.widget.Toolbar> 

Das ist mein 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" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.zaina.toolbar.MainActivity"> 
    <include android:id="@+id/aap_bar" layout="@layout/aap_bar"></include> 
    <TextView 
     android:layout_below="@id/aap_bar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" /> 
</RelativeLayout> 
+0

werden Sie Menüpunkte in Ihre Aktivität oder Fragment hinzufügen? – firegloves

+0

Wenn Sie die Menüeinträge hinzufügen möchten: @Override public boolean onCreateOptionsMenu (Menümenü) { new MenuInflate (this) .inflate (R.menu.your_menu_xml, menu); return (super.onCreateOptionsMenu (Menü)); } ' –

+0

Nein, ich möchte nur Symbol auf aap bar hier ist, ist" android: icon = "@ Zeichnungsfähige/ic_keyboard_arrow_right_black_24dp" "@ firegloves @ Charuka –

Antwort

0

Mein Problem wurde gelöst, weil ich diese Zeilen Code hinzufügen did'nt

@Override 
public boolean onCreateOptionsMenu(Menu item) { 
    getMenuInflater().inflate(R.menu.menu_main, item); 
    return true; 
}