Problem with icon not appearing on Android Actionbar

Source: Internet
Author: User

Again a support library problem, recently by this android.support.v4 and android.support.v7 tortured desperate, a lot of things because version changes have a lot of different. Since my project with fragment V4 Surpport package, so in the activity inheritance actionbaractivity inherited V7, do not know why the Action Bar item on the icon is not displayed. Check the cause.

The answer on the StackOverflow.

This was because if you use the support AppCompat ActionBar Library and actionbaractivity you should create your menus in a Different than the standard-of-the-creating XML menus in Actiobarsherlock or the default ActionBar.

<menu xmlns:android= "http://schemas.android.com/apk/res/android"       xmlns:app= "http://schemas.android.com/ Apk/res-auto ">      <item android:id=" @+id/action_search "          android:icon=" @drawable/ic_action_search "          android:title= "@string/action_search"          app:showasaction= "always"  />      <item android:id= "@+ Id/action_compose "          android:icon=" @drawable/ic_action_compose "          android:title=" @string/action_compose "           app:showasaction= "Always"/></menu>
Added a second line:

xmlns:app= "Http://schemas.android.com/apk/res-auto"
and change the downward android:showasaction= "always" to

Check the official documents also did not very clear, in short, is solved.

Android is really a pain in solving version compatibility issues ... How to say, recently summed up the experience is to be sure to Google, preferably in English, Baidu an afternoon than Google a few minutes to solve the problem =

Problem with icon not appearing on Android Actionbar

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.