Friday, January 17, 2014
Disabling ActionBar menu items
I have some use cases where I want to temporarily disable ActionBar menu items, such that they are not clickable, but also so they are a different color from the active ones. The default SetEnabled method on IMenuItem does not do this for you. Sure it disables the item, however the visual state does not change. Hence, I found a nifty way to change this and made my own SetEnabled extension method.
Using this extension method can grey out menu items, so they appear disabled from a UX perspective. The method takes some more parameters, as it needs to get the resource id of the Drawable you want to use for the greyed out item and the current Context, such that it can get it from the application resources.