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);