About Actionbar's pit.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.