If there is an ActionBar, this method hides or shows it, else does nothing. - Android User Interface

Android examples for User Interface:ActionBar

Description

If there is an ActionBar, this method hides or shows it, else does nothing.

Demo Code


//package com.java2s;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;

import android.os.Build;

public class Main {
    /**//from w w  w .j  a v  a  2  s .  c  o  m
     * If there is an ActionBar, this method hides or shows it, else does nothing.
     * @param act The activity which's ActionBar (if available) is to be shown or hidden.
     * @param hide If <code>true</code> the bar will be hidden, else shown if available.
     */
    @SuppressLint("NewApi")
    public static final void hideActionBar(Activity act, boolean hide) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ActionBar bar = act.getActionBar();
            if (bar != null) {
                if (hide) {
                    bar.hide();
                } else {
                    bar.show();
                }
            }
        }
    }
}

Related Tutorials