Search in sources :

Example 1 with ToolbarActionBar

use of com.android.internal.app.ToolbarActionBar in project platform_frameworks_base by android.

the class Activity method setActionBar.

/**
     * Set a {@link android.widget.Toolbar Toolbar} to act as the {@link ActionBar} for this
     * Activity window.
     *
     * <p>When set to a non-null value the {@link #getActionBar()} method will return
     * an {@link ActionBar} object that can be used to control the given toolbar as if it were
     * a traditional window decor action bar. The toolbar's menu will be populated with the
     * Activity's options menu and the navigation button will be wired through the standard
     * {@link android.R.id#home home} menu select action.</p>
     *
     * <p>In order to use a Toolbar within the Activity's window content the application
     * must not request the window feature {@link Window#FEATURE_ACTION_BAR FEATURE_ACTION_BAR}.</p>
     *
     * @param toolbar Toolbar to set as the Activity's action bar, or {@code null} to clear it
     */
public void setActionBar(@Nullable Toolbar toolbar) {
    final ActionBar ab = getActionBar();
    if (ab instanceof WindowDecorActionBar) {
        throw new IllegalStateException("This Activity already has an action bar supplied " + "by the window decor. Do not request Window.FEATURE_ACTION_BAR and set " + "android:windowActionBar to false in your theme to use a Toolbar instead.");
    }
    // If we reach here then we're setting a new action bar
    // First clear out the MenuInflater to make sure that it is valid for the new Action Bar
    mMenuInflater = null;
    // If we have an action bar currently, destroy it
    if (ab != null) {
        ab.onDestroy();
    }
    if (toolbar != null) {
        final ToolbarActionBar tbab = new ToolbarActionBar(toolbar, getTitle(), this);
        mActionBar = tbab;
        mWindow.setCallback(tbab.getWrappedWindowCallback());
    } else {
        mActionBar = null;
        // Re-set the original window callback since we may have already set a Toolbar wrapper
        mWindow.setCallback(this);
    }
    invalidateOptionsMenu();
}
Also used : WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar)

Example 2 with ToolbarActionBar

use of com.android.internal.app.ToolbarActionBar in project android_frameworks_base by ResurrectionRemix.

the class Activity method setActionBar.

/**
     * Set a {@link android.widget.Toolbar Toolbar} to act as the {@link ActionBar} for this
     * Activity window.
     *
     * <p>When set to a non-null value the {@link #getActionBar()} method will return
     * an {@link ActionBar} object that can be used to control the given toolbar as if it were
     * a traditional window decor action bar. The toolbar's menu will be populated with the
     * Activity's options menu and the navigation button will be wired through the standard
     * {@link android.R.id#home home} menu select action.</p>
     *
     * <p>In order to use a Toolbar within the Activity's window content the application
     * must not request the window feature {@link Window#FEATURE_ACTION_BAR FEATURE_ACTION_BAR}.</p>
     *
     * @param toolbar Toolbar to set as the Activity's action bar, or {@code null} to clear it
     */
public void setActionBar(@Nullable Toolbar toolbar) {
    final ActionBar ab = getActionBar();
    if (ab instanceof WindowDecorActionBar) {
        throw new IllegalStateException("This Activity already has an action bar supplied " + "by the window decor. Do not request Window.FEATURE_ACTION_BAR and set " + "android:windowActionBar to false in your theme to use a Toolbar instead.");
    }
    // If we reach here then we're setting a new action bar
    // First clear out the MenuInflater to make sure that it is valid for the new Action Bar
    mMenuInflater = null;
    // If we have an action bar currently, destroy it
    if (ab != null) {
        ab.onDestroy();
    }
    if (toolbar != null) {
        final ToolbarActionBar tbab = new ToolbarActionBar(toolbar, getTitle(), this);
        mActionBar = tbab;
        mWindow.setCallback(tbab.getWrappedWindowCallback());
    } else {
        mActionBar = null;
        // Re-set the original window callback since we may have already set a Toolbar wrapper
        mWindow.setCallback(this);
    }
    invalidateOptionsMenu();
}
Also used : WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar)

Example 3 with ToolbarActionBar

use of com.android.internal.app.ToolbarActionBar in project android_frameworks_base by crdroidandroid.

the class Activity method setActionBar.

/**
     * Set a {@link android.widget.Toolbar Toolbar} to act as the {@link ActionBar} for this
     * Activity window.
     *
     * <p>When set to a non-null value the {@link #getActionBar()} method will return
     * an {@link ActionBar} object that can be used to control the given toolbar as if it were
     * a traditional window decor action bar. The toolbar's menu will be populated with the
     * Activity's options menu and the navigation button will be wired through the standard
     * {@link android.R.id#home home} menu select action.</p>
     *
     * <p>In order to use a Toolbar within the Activity's window content the application
     * must not request the window feature {@link Window#FEATURE_ACTION_BAR FEATURE_ACTION_BAR}.</p>
     *
     * @param toolbar Toolbar to set as the Activity's action bar, or {@code null} to clear it
     */
public void setActionBar(@Nullable Toolbar toolbar) {
    final ActionBar ab = getActionBar();
    if (ab instanceof WindowDecorActionBar) {
        throw new IllegalStateException("This Activity already has an action bar supplied " + "by the window decor. Do not request Window.FEATURE_ACTION_BAR and set " + "android:windowActionBar to false in your theme to use a Toolbar instead.");
    }
    // If we reach here then we're setting a new action bar
    // First clear out the MenuInflater to make sure that it is valid for the new Action Bar
    mMenuInflater = null;
    // If we have an action bar currently, destroy it
    if (ab != null) {
        ab.onDestroy();
    }
    if (toolbar != null) {
        final ToolbarActionBar tbab = new ToolbarActionBar(toolbar, getTitle(), this);
        mActionBar = tbab;
        mWindow.setCallback(tbab.getWrappedWindowCallback());
    } else {
        mActionBar = null;
        // Re-set the original window callback since we may have already set a Toolbar wrapper
        mWindow.setCallback(this);
    }
    invalidateOptionsMenu();
}
Also used : WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar)

Example 4 with ToolbarActionBar

use of com.android.internal.app.ToolbarActionBar in project android_frameworks_base by AOSPA.

the class Activity method setActionBar.

/**
     * Set a {@link android.widget.Toolbar Toolbar} to act as the {@link ActionBar} for this
     * Activity window.
     *
     * <p>When set to a non-null value the {@link #getActionBar()} method will return
     * an {@link ActionBar} object that can be used to control the given toolbar as if it were
     * a traditional window decor action bar. The toolbar's menu will be populated with the
     * Activity's options menu and the navigation button will be wired through the standard
     * {@link android.R.id#home home} menu select action.</p>
     *
     * <p>In order to use a Toolbar within the Activity's window content the application
     * must not request the window feature {@link Window#FEATURE_ACTION_BAR FEATURE_ACTION_BAR}.</p>
     *
     * @param toolbar Toolbar to set as the Activity's action bar, or {@code null} to clear it
     */
public void setActionBar(@Nullable Toolbar toolbar) {
    final ActionBar ab = getActionBar();
    if (ab instanceof WindowDecorActionBar) {
        throw new IllegalStateException("This Activity already has an action bar supplied " + "by the window decor. Do not request Window.FEATURE_ACTION_BAR and set " + "android:windowActionBar to false in your theme to use a Toolbar instead.");
    }
    // If we reach here then we're setting a new action bar
    // First clear out the MenuInflater to make sure that it is valid for the new Action Bar
    mMenuInflater = null;
    // If we have an action bar currently, destroy it
    if (ab != null) {
        ab.onDestroy();
    }
    if (toolbar != null) {
        final ToolbarActionBar tbab = new ToolbarActionBar(toolbar, getTitle(), this);
        mActionBar = tbab;
        mWindow.setCallback(tbab.getWrappedWindowCallback());
    } else {
        mActionBar = null;
        // Re-set the original window callback since we may have already set a Toolbar wrapper
        mWindow.setCallback(this);
    }
    invalidateOptionsMenu();
}
Also used : WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar)

Example 5 with ToolbarActionBar

use of com.android.internal.app.ToolbarActionBar in project android_frameworks_base by DirtyUnicorns.

the class Activity method setActionBar.

/**
     * Set a {@link android.widget.Toolbar Toolbar} to act as the {@link ActionBar} for this
     * Activity window.
     *
     * <p>When set to a non-null value the {@link #getActionBar()} method will return
     * an {@link ActionBar} object that can be used to control the given toolbar as if it were
     * a traditional window decor action bar. The toolbar's menu will be populated with the
     * Activity's options menu and the navigation button will be wired through the standard
     * {@link android.R.id#home home} menu select action.</p>
     *
     * <p>In order to use a Toolbar within the Activity's window content the application
     * must not request the window feature {@link Window#FEATURE_ACTION_BAR FEATURE_ACTION_BAR}.</p>
     *
     * @param toolbar Toolbar to set as the Activity's action bar, or {@code null} to clear it
     */
public void setActionBar(@Nullable Toolbar toolbar) {
    final ActionBar ab = getActionBar();
    if (ab instanceof WindowDecorActionBar) {
        throw new IllegalStateException("This Activity already has an action bar supplied " + "by the window decor. Do not request Window.FEATURE_ACTION_BAR and set " + "android:windowActionBar to false in your theme to use a Toolbar instead.");
    }
    // If we reach here then we're setting a new action bar
    // First clear out the MenuInflater to make sure that it is valid for the new Action Bar
    mMenuInflater = null;
    // If we have an action bar currently, destroy it
    if (ab != null) {
        ab.onDestroy();
    }
    if (toolbar != null) {
        final ToolbarActionBar tbab = new ToolbarActionBar(toolbar, getTitle(), this);
        mActionBar = tbab;
        mWindow.setCallback(tbab.getWrappedWindowCallback());
    } else {
        mActionBar = null;
        // Re-set the original window callback since we may have already set a Toolbar wrapper
        mWindow.setCallback(this);
    }
    invalidateOptionsMenu();
}
Also used : WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) ToolbarActionBar(com.android.internal.app.ToolbarActionBar) WindowDecorActionBar(com.android.internal.app.WindowDecorActionBar)

Aggregations

ToolbarActionBar (com.android.internal.app.ToolbarActionBar)5 WindowDecorActionBar (com.android.internal.app.WindowDecorActionBar)5