AppCompatDelegate

abstract class AppCompatDelegate(source)

This class represents a delegate which you can use to extend AppCompat's support to any android.app.Activity.

When using an AppCompatDelegate, you should call the following methods instead of the android.app.Activity method of the same name:

The following methods should be called from the android.app.Activity method of the same name:

An Activity can only be linked with one AppCompatDelegate instance, therefore the instance returned from create should be retained until the Activity is destroyed.

Types

Link copied to clipboard

Properties

Link copied to clipboard
Flag for specifying the behavior of action modes when an Action Bar is not present.
Link copied to clipboard
Flag for enabling the support Action Bar.
Link copied to clipboard
Flag for requesting an support Action Bar that overlays window content.
Link copied to clipboard
Link copied to clipboard
Night mode which uses a dark mode when the system's 'Battery Saver' feature is enabled, otherwise it uses a 'light mode'.
Link copied to clipboard
Night mode which switches between dark and light mode depending on the time of day (dark at night, light in the day).
Link copied to clipboard
Mode which uses the system's night mode setting to determine if it is night or not.
Link copied to clipboard
Night mode which uses always uses a light mode, enabling notnight qualified resources regardless of the time.
Link copied to clipboard
An unspecified mode for night mode.
Link copied to clipboard
Night mode which uses always uses a dark mode, enabling night qualified resources regardless of the time.

Functions

Link copied to clipboard
Should be called instead of addContentView}
Link copied to clipboard
abstract fun applyDayNight(): Boolean
Applies the currently selected night mode to this delegate's host component.
Link copied to clipboard
open fun attachBaseContext(context: Context)
Link copied to clipboard
@NonNull
open fun attachBaseContext2(@NonNull context: @NonNull Context): @NonNull Context
Should be called from attachBaseContext.
Link copied to clipboard
@NonNull
open fun create(@NonNull activity: @NonNull Activity, @Nullable callback: @Nullable AppCompatCallback): @NonNull AppCompatDelegate
Create an androidx.appcompat.app.AppCompatDelegate to use with activity.
@NonNull
open fun create(@NonNull dialog: @NonNull Dialog, @Nullable callback: @Nullable AppCompatCallback): @NonNull AppCompatDelegate
Create an androidx.appcompat.app.AppCompatDelegate to use with dialog.
@NonNull
open fun create(@NonNull context: @NonNull Context, @NonNull activity: @NonNull Activity, @Nullable callback: @Nullable AppCompatCallback): @NonNull AppCompatDelegate
Create an androidx.appcompat.app.AppCompatDelegate to use with a context and hosted by an Activity.
@NonNull
open fun create(@NonNull context: @NonNull Context, @NonNull window: @NonNull Window, @Nullable callback: @Nullable AppCompatCallback): @NonNull AppCompatDelegate
Create an androidx.appcompat.app.AppCompatDelegate to use with a context and a window.
Link copied to clipboard
abstract fun createView(@Nullable parent: @Nullable View, name: String, @NonNull context: @NonNull Context, @NonNull attrs: @NonNull AttributeSet): View
This should be called from a LayoutInflater.Factory2 in order to return tint-aware widgets.
Link copied to clipboard
abstract fun <T : View?> findViewById(@IdRes id: Int): @Nullable T
Finds a view that was identified by the id attribute from the XML that was processed in onCreate.
Link copied to clipboard
@NonNull
open fun getApplicationLocales(): @NonNull LocaleListCompat
Returns application locales for the calling app as a LocaleListCompat.
Link copied to clipboard
@Nullable
open fun getContextForDelegate(): @Nullable Context
Returns the context for the current delegate.
Link copied to clipboard
Returns the default night mode.
Link copied to clipboard
Returns an ActionBarDrawerToggle.Delegate which can be returned from your Activity if it implements ActionBarDrawerToggle.DelegateProvider.
Link copied to clipboard
Returns the night mode previously set via getLocalNightMode.
Link copied to clipboard
Return the value of this call from your getMenuInflater
Link copied to clipboard
@Nullable
abstract fun getSupportActionBar(): @Nullable ActionBar
Support library version of getActionBar.
Link copied to clipboard
abstract fun hasWindowFeature(featureId: Int): Boolean
Query for the availability of a certain feature.
Link copied to clipboard
abstract fun installViewFactory()
Installs AppCompat's android.view.LayoutInflater Factory so that it can replace the framework widgets with compatible tinted versions.
Link copied to clipboard
Link copied to clipboard
Returns whether vector drawables on older platforms (< API 21) can be accessed from within resources.
Link copied to clipboard
Returns whether AppCompat handles any native action modes itself.
Link copied to clipboard
abstract fun onConfigurationChanged(newConfig: Configuration)
Should be called from onConfigurationChanged
Link copied to clipboard
abstract fun onCreate(savedInstanceState: Bundle)
Should be called from Activity.
Link copied to clipboard
abstract fun onDestroy()
Should be called from onDestroy
Link copied to clipboard
abstract fun onPostCreate(savedInstanceState: Bundle)
Should be called from onPostCreate
Link copied to clipboard
abstract fun onPostResume()
Should be called from onPostResume
Link copied to clipboard
abstract fun onSaveInstanceState(outState: Bundle)
Allows AppCompat to save instance state.
Link copied to clipboard
abstract fun onStart()
Should be called from onStart Activity.
Link copied to clipboard
abstract fun onStop()
Should be called from Activity.onStop()
Link copied to clipboard
abstract fun requestWindowFeature(featureId: Int): Boolean
Enable extended window features.
Link copied to clipboard
open fun setApplicationLocales(@NonNull locales: @NonNull LocaleListCompat)
Sets the current locales for the calling app.
Link copied to clipboard
Sets whether vector drawables on older platforms (< API 21) can be used within android.graphics.drawable.DrawableContainer resources.
Link copied to clipboard
abstract fun setContentView(v: View)
abstract fun setContentView(@LayoutRes resId: Int)
Should be called instead of setContentView}
Link copied to clipboard
open fun setDefaultNightMode(mode: Int)
Sets the default night mode.
Link copied to clipboard
Whether AppCompat handles any native action modes itself.
Link copied to clipboard
abstract fun setLocalNightMode(mode: Int)
Override the night mode used for this delegate's host component.
Link copied to clipboard
@RequiresApi(value = 33)
open fun setOnBackInvokedDispatcher(@Nullable dispatcher: @Nullable OnBackInvokedDispatcher)
Sets the OnBackInvokedDispatcher for handling system back for Android SDK 33 and above.
Link copied to clipboard
abstract fun setSupportActionBar(@Nullable toolbar: @Nullable Toolbar)
Set a Toolbar to act as the ActionBar for this delegate.
Link copied to clipboard
open fun setTheme(@StyleRes themeResId: Int)
This should be called from setTheme to notify AppCompat of what the current theme resource id is.
Link copied to clipboard
abstract fun setTitle(@Nullable title: @Nullable CharSequence)
Should be called from onTitleChanged}
Link copied to clipboard
@Nullable
abstract fun startSupportActionMode(callback: @NonNull ActionMode.Callback): @Nullable ActionMode
Start an action mode.