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.
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() .
| |||||||||||
Installs AppCompat's
LayoutInflater Factory so that it can replace
the framework widgets with compatible tinted versions.
| |||||||||||
Should be called from
invalidateOptionsMenu() } or
supportInvalidateOptionsMenu() .
| |||||||||||
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) }
| |||||||||||
Should be called from
onTitleChanged(CharSequence, int) }
| |||||||||||
Start an action mode.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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()
.
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()
.
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)
}
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_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 |
---|