简体   繁体   中英

Android App: How can I change the icon of my Action Bar without using manifest.xml and setting minVersion to 14?

So i want to change the Icon of the ActionBar. Since the icon image depends on some input data from the user, I cannot use the manifest.xml

I also dont want to use setIcon Method because then I have to set up the minimal version to 14.

So is there any other way?

I also dont want to use setIcon Method because then I have to set up the minimal version to 14.

There are three possibilities for your minSdkVersion :

  1. If your minSdkVersion is 10 or below, you should be using the "AppCompat" edition of the action bar, and it has a setIcon() method (or use ActionBarSherlock, and it too has setIcon() )

  2. If your minSdkVersion is 14 or higher, use setIcon() on the regular ActionBar

  3. If your minSdkVersion is 11, 12, or 13, change it to be something else, as none of those values make much sense based on the distribution of Android devices in use today

如果您不想使用“设置图标方法”,则可以使用“ 支持库”或“ Action Bar Sherlock库” ...没有其他选择

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM