Change Android Action Bar Menu Item's Icon On Click
I'm using sherlock action bar. I have 2 items on the action bar. When the item is chosen (active), I want to change the icon's image. This is my code on Java @Override publ
Solution 1:
Use the on onOptionsItemSelected method
@OverridepublicbooleanonOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.todaySched:
// put your code here to change the iconreturntrue;
default:
returnsuper.onOptionsItemSelected(item);
}
}
you may need to include the correct namespace for the ActionBar Sherlock library to ensure it Overrides the correct menu item. So the start of the method will look like this:
@OverridepublicbooleanonOptionsItemSelected(com.actionbarsherlock.view.MenuItem item)
Post a Comment for "Change Android Action Bar Menu Item's Icon On Click"