Search code examples
androidandroid-actionbar

Check action bar is hidden or visible in android


I want to check action bar is hidden or visible when double tap on a WebView. My code is :

@Override
public boolean onDoubleTapEvent(MotionEvent e) {
    if (getSupportActionBar().isShowing()){
        getSupportActionBar().hide();
    }else {
        getSupportActionBar().show();
    }

    //view.zoomIn();//Zoom in
    return true;
}

I want to check if action bar is visible.If its visible when double tap event occurs it should hide the action bar,

if it is hidden at first time then it should display the action bar when double tap occurs .

But above code generates error. so please help me to make a code working.


Solution

  • You must define your actionbar first. So

    ActionBar actionBar = getSupportActionBar();
    

    Now you could do actionBar.hide() or actionBar.show().