java.lang.Object | |
↳ | android.support.v7.app.AppCompatDelegate |
This class represents a delegate which you can use to extend AppCompat's support to any
Activity
.
When using an AppCompatDelegate
, you should any methods exposed in it rather than the
Activity
method of the same name. This applies to:
addContentView(android.view.View, android.view.ViewGroup.LayoutParams)
setContentView(int)
setContentView(android.view.View)
setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
requestWindowFeature(int)
invalidateOptionsMenu()
startSupportActionMode(android.support.v7.view.ActionMode.Callback)
setSupportActionBar(android.support.v7.widget.Toolbar)
getSupportActionBar()
getMenuInflater()
onCreate(android.os.Bundle)
onPostCreate(android.os.Bundle)
onConfigurationChanged(android.content.res.Configuration)
setTitle(CharSequence)
onStop()
onDestroy()
An Activity
can only be linked with one AppCompatDelegate
instance,
so the instance returned from create(Activity, AppCompatCallback)
should be kept
until the Activity is destroyed.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FEATURE_ACTION_MODE_OVERLAY | Flag for specifying the behavior of action modes when an Action Bar is not present. | |||||||||
int | FEATURE_SUPPORT_ACTION_BAR | Flag for enabling the support Action Bar. | |||||||||
int | FEATURE_SUPPORT_ACTION_BAR_OVERLAY | Flag for requesting an support Action Bar that overlays window content. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Should be called instead of
addContentView(android.view.View, android.view.ViewGroup.LayoutParams) }
| |||||||||||
Create a
AppCompatDelegate to use with activity .
| |||||||||||
Create a
AppCompatDelegate to use with dialog .
| |||||||||||
This should be called from a
LayoutInflaterFactory in order
to return tint-aware widgets.
| |||||||||||
Returns an
ActionBarDrawerToggle.Delegate which can be returned from your Activity
if it implements ActionBarDrawerToggle.DelegateProvider .
| |||||||||||
Return the value of this call from your
getMenuInflater()
| |||||||||||
Support library version of
getActionBar() .
| |||||||||||
Query for the availability of a certain feature.
| |||||||||||
Installs AppCompat's
LayoutInflater Factory so that it can replace
the framework widgets with compatible tinted versions.
| |||||||||||
Should be called from
invalidateOptionsMenu() } or
supportInvalidateOptionsMenu() .
| |||||||||||
Returns whether AppCompat handles any native action modes itself.
| |||||||||||
Should be called from
onConfigurationChanged(Configuration)
| |||||||||||
Should be called from
Activity.onCreate()
| |||||||||||
Should be called from
onDestroy()
| |||||||||||
Should be called from
onPostCreate(android.os.Bundle)
| |||||||||||
Should be called from
onPostResume()
| |||||||||||
Should be called from
Activity.onStop()
| |||||||||||
Enable extended window features.
| |||||||||||
Should be called instead of
setContentView(int) }
| |||||||||||
Should be called instead of
setContentView(android.view.View) }
| |||||||||||
Should be called instead of
setContentView(android.view.View, android.view.ViewGroup.LayoutParams) }
| |||||||||||
Whether AppCompat handles any native action modes itself.
| |||||||||||
Should be called from
onTitleChanged(CharSequence, int) }
| |||||||||||
Start an action mode.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Flag for specifying the behavior of action modes when an Action Bar is not present. If overlay is enabled, the action mode UI will be allowed to cover existing window content.
Flag for enabling the support Action Bar.
This is enabled by default for some devices. The Action Bar replaces the title bar and provides an alternate location for an on-screen menu button on some devices.
Flag for requesting an support Action Bar that overlays window content.
Normally an Action Bar will sit in the space above window content, but if this
feature is requested along with FEATURE_SUPPORT_ACTION_BAR
it will be layered over
the window content itself. This is useful if you would like your app to have more control
over how the Action Bar is displayed, such as letting application content scroll beneath
an Action Bar with a transparent background or otherwise displaying a transparent/translucent
Action Bar over application content.
This mode is especially useful with View.SYSTEM_UI_FLAG_FULLSCREEN
, which allows
you to seamlessly hide the action bar in conjunction with other screen decorations.
When an ActionBar is in this mode it will adjust the insets provided to
View.fitSystemWindows(Rect)
to include the content covered by the action bar, so you can do layout within
that space.
Should be called instead of
addContentView(android.view.View, android.view.ViewGroup.LayoutParams)
}
Create a AppCompatDelegate
to use with activity
.
callback | An optional callback for AppCompat specific events |
---|
Create a AppCompatDelegate
to use with dialog
.
callback | An optional callback for AppCompat specific events |
---|
This should be called from a
LayoutInflaterFactory
in order
to return tint-aware widgets.
This is only needed if you are using your own
LayoutInflater
factory, and have therefore not
installed the default factory via installViewFactory()
.
Returns an ActionBarDrawerToggle.Delegate
which can be returned from your Activity
if it implements ActionBarDrawerToggle.DelegateProvider
.
Return the value of this call from your getMenuInflater()
Support library version of getActionBar()
.
Query for the availability of a certain feature.
This should be called instead of hasFeature(int)
.
featureId | The feature ID to check |
---|
Installs AppCompat's LayoutInflater
Factory so that it can replace
the framework widgets with compatible tinted versions. This should be called before
super.onCreate()
as so:
protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory(); super.onCreate(savedInstanceState); getDelegate().onCreate(savedInstanceState); // ... }If you are using your own
Factory
or
Factory2
then you can omit this call, and instead call
createView(android.view.View, String, android.content.Context, android.util.AttributeSet)
from your factory to return any compatible widgets.
Should be called from invalidateOptionsMenu()
} or
supportInvalidateOptionsMenu()
.
Returns whether AppCompat handles any native action modes itself.
Should be called from
onConfigurationChanged(Configuration)
Should be called from onPostCreate(android.os.Bundle)
Enable extended window features. This should be called instead of
requestWindowFeature(int)
or
getWindow().requestFeature()
.
featureId | The desired feature as defined in Window . |
---|
Should be called instead of setContentView(android.view.View)
}
Should be called instead of
setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
}
Whether AppCompat handles any native action modes itself.
This methods only takes effect on
ICE_CREAM_SANDWICH
and above.
enabled | whether AppCompat should handle native action modes. |
---|
Set a Toolbar
to act as the ActionBar
for this delegate.
When set to a non-null value the getSupportActionBar()
()} 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
home
menu select action.
In order to use a Toolbar within the Activity's window content the application
must not request the window feature
FEATURE_SUPPORT_ACTION_BAR
.
toolbar | Toolbar to set as the Activity's action bar |
---|
Should be called from onTitleChanged(CharSequence, int)
}
Start an action mode.
callback | Callback that will manage lifecycle events for this context mode |
---|