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


open class FragmentActivity : ComponentActivity, ActivityCompat.OnRequestPermissionsResultCallback, RequestPermissionsRequestCodeValidator

Base class for activities that want to use the support-based Fragments.

Known limitations:

  • When using the <fragment> tag, this implementation can not use the parent view's ID as the new fragment's ID. You must explicitly specify an ID (or tag) in the <fragment>.


Public constructors

Default constructor for FragmentActivity.

<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
dump(@NonNull prefix: String, @Nullable fd: FileDescriptor?, @NonNull writer: PrintWriter, @Nullable args: Array<String!>?)

Print the Activity's state into the given stream.

open FragmentManager

Return the FragmentManager for interacting with fragments associated with this activity.

open LoaderManager

open Unit
onAttachFragment(@NonNull fragment: Fragment)

Called when a fragment is attached to the activity.

open Unit

Dispatch configuration change to all fragments.

open Boolean
onCreatePanelMenu(featureId: Int, @NonNull menu: Menu)

Dispatch to Fragment.

open View?
onCreateView(@Nullable parent: View?, @NonNull name: String, @NonNull context: Context, @NonNull attrs: AttributeSet)

open View?
onCreateView(@NonNull name: String, @NonNull context: Context, @NonNull attrs: AttributeSet)

open Unit

Dispatch onLowMemory() to all fragments.

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

Dispatch context and options menu to fragments.

open Unit
onMultiWindowModeChanged(isInMultiWindowMode: Boolean)

Note: If you override this method you must call super.onMultiWindowModeChanged to correctly dispatch the event to support fragments attached to this activity.

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

Call onOptionsMenuClosed() on fragments.

open Unit
onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)

Note: If you override this method you must call super.onPictureInPictureModeChanged to correctly dispatch the event to support fragments attached to this activity.

open Boolean
onPreparePanel(featureId: Int, @Nullable view: View?, @NonNull menu: Menu)

Dispatch onPrepareOptionsMenu() to fragments.

open Unit
onRequestPermissionsResult(requestCode: Int, @NonNull permissions: Array<String!>, @NonNull grantResults: IntArray)

open Unit

Hook in to note that fragment state is no longer saved.