共用方式為


Activity.SetActionBar(Toolbar) Method

Definition

Set a android.widget.Toolbar Toolbar to act as the ActionBar for this Activity window.

[Android.Runtime.Register("setActionBar", "(Landroid/widget/Toolbar;)V", "GetSetActionBar_Landroid_widget_Toolbar_Handler")]
public virtual void SetActionBar (Android.Widget.Toolbar? toolbar);
[<Android.Runtime.Register("setActionBar", "(Landroid/widget/Toolbar;)V", "GetSetActionBar_Landroid_widget_Toolbar_Handler")>]
abstract member SetActionBar : Android.Widget.Toolbar -> unit
override this.SetActionBar : Android.Widget.Toolbar -> unit

Parameters

toolbar
Toolbar

Toolbar to set as the Activity's action bar, or null to clear it

Attributes

Remarks

Set a android.widget.Toolbar Toolbar to act as the ActionBar for this Activity window.

When set to a non-null value the #getActionBar() method will return an 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 android.R.id#home home menu select action.

In order to use a Toolbar within the Activity's window content the application must not request the window feature Window#FEATURE_ACTION_BAR FEATURE_ACTION_BAR.

Java documentation for android.app.Activity.setActionBar(android.widget.Toolbar).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to