Icon not displayed on Android ActionBar

Source: Internet
Author: User

Icon not displayed on Android ActionBar

It is also a support library problem. Recently, this android. support. v4 and android. support. v7 have been plagued by death and many things are different because of version changes. Because my project uses the v4 surpport package of Fragment, the ActionBarActivity inherits v7 from the Activity. I don't know why the Item icon is not displayed on the Operation bar. Check the cause

The answer on StackOverFlow.

This is because if you use the support AppCompat ActionBar library and ActionBarActivity you shoshould create your menus in a different than the standard way of creating xml menus in ActioBarSherlock or the default ActionBar.

 

      Added the second line: 

 

 

xmlns:app="http://schemas.android.com/apk/res-auto"
And change the Android: showAsAction = "always"

 

 

 app:showAsAction="always" 
I did not quite understand what I found in the official documentation. In short, it solved the problem.

 

Android is really a pain point in solving version compatibility issues... What should I do? The recently concluded experience is that Google must be used. It is best to check in English. Baidu may not solve the problem as long as google does in the afternoon =

 

This solves the problem of not displaying app icons. If you are drunk, add the following to the oncreate method of activity:

 

ActionBar actionBar = getSupportActionBar();actionBar.setLogo(R.drawable.ic_launcher);actionBar.setDisplayUseLogoEnabled(true);actionBar.setDisplayShowHomeEnabled(true);


 

Related Article

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.