I'm following the this Android tutorial. However, I couldn't place the action button on the action bar. It is always hidden in the overflow. I looked up some related questions Action buttons doesn't show up on Action Bar? as well as this one: Actionbar not shown with AppCompat
But none of them worked for me.
My res/menu/main.xml looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.gettingstarted.MainActivity" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
<item android:id="@+id/action_search"
android:title="@string/action_search"
android:icon="@drawable/ic_action_search"
android:showAsAction="always"
android:actionViewClass="android.widget.SearchView"/>
</menu>
And the src/MainActivity.java is as follows:
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
I created the folder drawable under /res and added the ic_action_search.png in that folder. Below is the what it looks like when I run the app.
The Search is still hidden in the overflow. Any ideas?