android - Menu not refreshing on some devices -


i have problem strange menu behavior on devices. do, showing/hiding menu items according application state. i'm using actionbarsherlock. code is:

private menuitem savemi; private menuitem postmi; private menuitem editmi;  @override public boolean oncreateoptionsmenu(menu menu) {     menuinflater inflater = getsupportmenuinflater();     inflater.inflate(r.menu.menu_main, menu);     savemi = menu.finditem(r.id.menu_save);     postmi = menu.finditem(r.id.menu_post);     editmi = menu.finditem(r.id.menu_edit);     if (app != null) {         app.setcurrentstate();     }     return true; } void setglobalstate(state state, object menuitem, string title) {     getsupportactionbar().settitle(title);     boolean showsavemenu = true;     boolean showpostmenu = true;     boolean showeditmenu = true;     switch (state) {     case editing:         showsavemenu = false;         showpostmenu = true;         showeditmenu = false;         break;     case viewing:         showsavemenu = false;         showpostmenu = true;         showeditmenu = true;         break;     case editing_needtosave:         showsavemenu = true;         showpostmenu = true;         showeditmenu = false;         break;     case img_editing:     case posting:     case not_post:     case new_post:     case choosing_accs:         showsavemenu = false;         showpostmenu = false;         showeditmenu = false;         break;     }     if (savemi != null) {         savemi.setvisible(showsavemenu);     }     if (postmi != null) {         postmi.setvisible(showpostmenu);     }     if (editmi != null) {         editmi.setvisible(showeditmenu);     }     invalidateoptionsmenu();     supportinvalidateoptionsmenu(); } 

actually, works fine on pure android. tested on lot amount of devices. there devices, suppose ignoring menu changes, , menu items remain invisible whatever state set. now, saw on 2 devices: huawei s7-701u tablet, , sony xperia phone. i'm afraid, vendors changed actionbar in firmware... so, can me normal behavior on devices?

edited mentioned, if don't call hide menu items @ application start, appear in actionbar. cannot hide them @ all. so, seems actionbar on devices doesn't receive invalidate call. still stuck, need help.

if interesting, found solution myself. transferred code setglobalstate method oncreateoptionsmenu, , removed class fields menu items - worked.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -