Disable Action Bar button in Android -


is possible disable button in action bar in android? looking around , not find code snippet that, thinking there should easy way.

  1. once perform user action when want disable action bar, set flag, disablebuttonflag.

  2. call invalidateoptionsmenu(). trigger oncreateoptionsmenu invoked regenerate menu.

  3. finally modify oncreateoptionsmenu disable button want depending on state of disablebuttonflag.

    if (disablebuttonflag) {     menu.finditem(r.id.your_item).setenabled(false); } else {     menu.finditem(r.id.your_item).setenabled(true); } 

    or more simply:

    menu.finditem(r.id.your_item).setenabled(!disablebuttonflag); 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -