I'm trying to update the menu buttons of my app every time one of them is pressed; in API 11+, you need to call invalidateOptionsMenu()
to do this; since I want my app to be compatible with lower APIs, how do I only call this method when using api 11+?
Use
ActivityCompat.invalidateOptionsMenu(Activity activity)
from the compatibility library.
For the others who are looking for an answer like I was:
If you are using ActionBarSherlock and trying to refresh the action bar buttons on API <11, instead of
Activity.invalidateOptionsMenu()
you can use
SherlockActivity.supportInvalidateOptionsMenu()
:
If you are extending ActionBarActivity in your class then you just need this:
supportInvalidateOptionsMenu();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With