Some versions of the phone's actionbar settings are not displayed (such as my phone)
<Menuxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Tools:context=". Mainactivity "> <ItemAndroid:icon= "@drawable/abc_ic_search_api_mtrl_alpha"Android:id= "@+id/action_search"Android:title= "Search"android:showasaction= "Ifroom" /> <ItemAndroid:id= "@+id/action_settings"Android:title= "@string/action_settings"Android:icon= "@drawable/abc_ic_menu_share_mtrl_alpha"android:showasaction= "Ifroom" /></Menu>
Search and setting will only appear in the menu displayed in the Menu key. You need to change the XML file above to:
<Menuxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Tools:context=". Mainactivity "> <ItemAndroid:icon= "@drawable/abc_ic_search_api_mtrl_alpha"Android:id= "@+id/action_search"Android:title= "Search" app:showasaction= "Ifroom" /> <ItemAndroid:id= "@+id/action_settings"Android:title= "@string/action_settings"Android:icon= "@drawable/abc_ic_menu_share_mtrl_alpha" app:showasaction= "Ifroom" /></Menu>
Change Android:showasaction to App:showasaction,actionbar to display normally
The answer is finally found in the StackOverflow: action Bar not displaying action Items (all in Overflow) Android. Originally because I use is android.support.v7.app.ActionBarActivity, therefore in the XML file, should change android:showasaction to app:showasaction.
Above.
About Actionbar's pit.