android - How can I show mActionBar when it's invisible, and hide it when it's visible? -


my current code shows mactionbar.
how can switch hide or show , force?

@override public boolean onkeydown(int keycode, keyevent event) { if(keycode == keyevent.keycode_menu){             mactionbar.show(); }else if(keycode == keyevent.keycode_back){     webview  mywebview = (webview)findviewbyid(r.id.webview1);     mywebview.goback(); } return true; }        

as actionbar has isshowing() method, can use check if visible or not, , decide whether needs shown or hidden. code should work, haven't tested it.

private void toggleactionbar() {     if (mactionbar.isshowing()) {         mactionbar.hide();     }     else {         mactionbar.show();     } } 

then can replace mactionbar.show() in code snippet instead call toggleactionbar().


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -