Google 致力于为黑人社区推动种族平等。查看具体举措

AppCompatActivity

open class AppCompatActivity : FragmentActivity, AppCompatCallback, TaskStackBuilder.SupportParentable, ActionBarDrawerToggle.DelegateProvider
androidx.activity.ComponentActivity
   ↳ androidx.fragment.app.FragmentActivity
   ↳ androidx.appcompat.app.AppCompatActivity

Base class for activities that wish to use some of the newer platform features on older Android devices. Some of these backported features include:

Note that every activity that extends this class has to be themed with Theme.AppCompat or a theme that extends that theme.

Summary

Public constructors

Default constructor for AppCompatActivity.

<init>(@LayoutRes contentLayoutId: Int)

Alternate constructor that can be used to provide a default layout that will be inflated as part of super.onCreate(savedInstanceState).

Public methods
open Unit
addContentView(view: View!, params: LayoutParams!)

open Unit

open Boolean

open T
findViewById(@IdRes id: Int)

open AppCompatDelegate

open ActionBarDrawerToggle.Delegate?

open MenuInflater

open Resources!

open ActionBar?

Support library version of android.app.Activity#getActionBar.

open Intent?

Obtain an android.content.Intent that will launch an explicit target activity specified by sourceActivity's androidx.core.app.NavUtils#PARENT_ACTIVITY <meta-data> element in the application's manifest.

open Unit

open Unit

open Unit

open Unit

Support version of onCreateNavigateUpTaskStack(android.app.TaskStackBuilder).

open Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)

Boolean
onMenuItemSelected(featureId: Int, @NonNull item: MenuItem)

open Boolean
onMenuOpened(featureId: Int, menu: Menu)

Please note: AppCompat uses its own feature id for the action bar: FEATURE_SUPPORT_ACTION_BAR.

open Unit
onPanelClosed(featureId: Int, @NonNull menu: Menu)

Call onOptionsMenuClosed() on fragments.

open Unit

Support version of onPrepareNavigateUpTaskStack(android.app.TaskStackBuilder).

open Unit

Notifies the activity that a support action mode has finished.

open Unit

Notifies the Activity that a support action mode has been started.

open Unit

open Boolean

This method is called whenever the user chooses to navigate Up within your application's activity hierarchy from the action bar.

open ActionMode?

Called when a support action mode is being started for this window.

open Unit

open Unit
setContentView(@LayoutRes layoutResID: Int)

open Unit

open Unit
setContentView(view: View!, params: LayoutParams!)

open Unit
setSupportActionBar(@Nullable toolbar: Toolbar?)

Set a Toolbar to act as the androidx.appcompat.app.ActionBar for this Activity window.

open Unit

open Unit

open Unit

open Unit

open Unit
setTheme(@StyleRes resId: Int)

open ActionMode?

Start an action mode.

open Unit

open Unit
supportNavigateUpTo(@NonNull upIntent: Intent)

Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity in the process.

open Boolean

Enable extended support library window features.

open Boolean
supportShouldUpRecreateTask(@NonNull targetIntent: Intent)

Returns true if sourceActivity should recreate the task when navigating 'up' by using targetIntent.

Protected methods
open Unit

open Unit

open Unit

Called when the night mode has changed.

open Unit
onPostCreate(@Nullable savedInstanceState: Bundle?)

open Unit

open Unit

open Unit

open Unit
onTitleChanged(title: CharSequence!, color: Int)

Inherited functions