简体   繁体   中英

Android Action bar not showing Icons

How can i display Icons in Actions bar, here is my code,

<?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/search_icon"
    android:icon="@drawable/ic_action_search"
    android:showAsAction="always"
    android:orderInCategory="0"
    android:title="Search" >
</item>
</menu>

and

@Override
public boolean onCreateOptionsMenu(Menu menu){
    MenuInflater mif = getMenuInflater();
    mif.inflate(R.menu.custom_action_bar,menu);
    return super.onCreateOptionsMenu(menu);
}

Thanks for Help !

If using app compat use app:showAsAction

<item android:id="@+id/search_icon"
    android:icon="@drawable/ic_action_search"
    app:showAsAction="always"
    android:orderInCategory="100"
    android:title="Search" >
</item>

In Manifest.xml File

    <activity android:name="your activity name"
        android:theme="@style/Theme.Holo.Light"></activity>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM