简体   繁体   中英

How do I get ActionBarCompat to show the normal default icon (set in the application/intent-filter android:icon attribute in the manifest)?

Any clues on how to get ActionBarCompat to show the default icon in pre-honeycomb devices the normal honeycomb/ics action bar would show? ie the icon set in the <application> / <intent-filter> android:icon attribute in the manifest.

Also information on how to get the resource ID for the android:icon would be helpful.

Thanks

Well, for pre-Honeycomb, you'll have to change the icon referenced by the 'HOME' ActionBar element in ActionBarHelperBase.java class. This should be somewhere in the setupActionBar() method, like so:

homeItem.setIcon(R.drawable.ic_home);

Just change this to

homeItem.setIcon(R.drawable.launcher);

and you should be good to go. For changing in Honeycomb, you'll need to change the android:icon attributes in values-v11\\styles.xml in the style for ActionBar .

Hope that helps.

Also information on how to get the resource ID for the android:icon would be helpful.

What? If you use: android:icon="@drawable/ic_launcher" then the resource id is R.drawable.ic_launcher .

Also, you mention ActionBarCompat ... are you using ActionBarSherlock? if so it should show that icon by default. What are you seeing instead?

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