I am following the tutorial of the following site in adding button to action bar http://developer.android.com/training/basics/actionbar/adding-buttons.html#AddActions
Following the tutorial, I have created a new XML file, \res\menu\main_activity_actions.xml with the following content
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- search, should appear as action button -->
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
android:orderInCategory="100"
android:showAsAction="always" />
<!-- Settings, should always be in the overflow -->
<item android:id="@id/action_settings"
android:title="@string/action_settings"
android:showAsAction="never" />
</menu>
And my MainActivity.java, I have modified the onCreateOptionsMenus() as follow
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
However, after compilation, I can only the search and setting button after pressing menu button, not showing in the actiionbar by deafult. Any hints?
Thanks
JC