Is it possible on Android to have MenuItems (either the ones from the options menu hardware key or action bar — they are the same anyways) with different styles?
I want one to have a selector applied and another with different selector.
From my search online, I found that you can change the theme and override an attribute with your own style, but that applies to ALL MenuItems.
Can I still set the android:background property in XML?
It is possible for items of the
ActionBar. You have to define the item that you want to have a different selector as a custom action view.In the layout referenced by
android:actionLayoutyou have anImageViewthat you assign your selector and make it clickable and focusable.The click event is not handled by
onOptionsItemSelected. You have to attach anOnClickListenerinonCreateOptionsMenu.