Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

Fragment

open class Fragment : ComponentCallbacks, OnCreateContextMenuListener, LifecycleOwner, ViewModelStoreOwner, HasDefaultViewModelProviderFactory, SavedStateRegistryOwner, ActivityResultCaller
kotlin.Any
   ↳ androidx.fragment.app.Fragment

Static library support version of the framework's android.app.Fragment. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework android.app.Fragment documentation for a class overview.

The main differences when using this support version instead of the framework version are:

Summary

Nested classes
open

Thrown by FragmentFactory#instantiate(ClassLoader, String) when there is an instantiation failure.

open

State information that has been retrieved from a fragment instance through FragmentManager.saveFragmentInstanceState.

Public constructors

Constructor used by the default FragmentFactory.

<init>(@LayoutRes contentLayoutId: Int)

Alternate constructor that can be called from your default, no argument constructor to provide a default layout that will be inflated by onCreateView(LayoutInflater, ViewGroup, Bundle).

Public methods
open Unit
dump(@NonNull prefix: String, @Nullable fd: FileDescriptor?, @NonNull writer: PrintWriter, @Nullable args: Array<String!>?)

Print the Fragments's state into the given stream.

Boolean
equals(@Nullable other: Any?)

Subclasses can not override equals().

FragmentActivity?

Return the FragmentActivity this fragment is currently associated with.

open Boolean

Returns whether the the exit transition and enter transition overlap or not.

open Boolean

Returns whether the the return transition and reenter transition overlap or not.

Bundle?

Return the arguments supplied when the fragment was instantiated, if any.

FragmentManager

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

open Context?

Return the Context this fragment is currently associated with.

open ViewModelProvider.Factory

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

open Any?

Returns the Transition that will be used to move Views into the initial scene.

open Any?

Returns the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.

FragmentManager?

Return the FragmentManager for interacting with fragments associated with this fragment's activity.

Any?

Return the host object of this fragment.

Int

Return the identifier this fragment is known by.

LayoutInflater

Returns the cached LayoutInflater used to inflate Views of this Fragment.

open Lifecycle

Returns the Lifecycle of the provider.

open LoaderManager

Return the LoaderManager for this fragment.

Fragment?

Returns the parent Fragment containing this Fragment.

FragmentManager

Return the FragmentManager for interacting with fragments associated with this fragment's activity.

open Any?

Returns the Transition that will be used to move Views in to the scene when returning due to popping a back stack.

Resources

Return requireActivity().getResources().

Boolean

Returns true if this fragment instance's state will be retained across configuration changes, and false if it will not.

open Any?

Returns the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.

SavedStateRegistry

open Any?

Returns the Transition that will be used for shared elements transferred into the content Scene.

open Any?

Return the Transition that will be used for shared elements transferred back during a pop of the back stack.

String
getString(@StringRes resId: Int)

Return a localized string from the application's package's default string table.

String
getString(@StringRes resId: Int, @Nullable vararg formatArgs: Any!)

Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in java.util.Formatter and java.

String?

Get the tag name of the fragment, if specified.

Fragment?

Return the target fragment set by setTargetFragment.

Int

Return the target request code set by setTargetFragment.

CharSequence
getText(@StringRes resId: Int)

Return a localized, styled CharSequence from the application's package's default string table.

open Boolean

open View?

Get the root view for the fragment's layout (the one returned by onCreateView), if provided.

open LifecycleOwner

Get a LifecycleOwner that represents the Fragment's View lifecycle.

open LiveData<LifecycleOwner!>

Retrieve a LiveData which allows you to observe the lifecycle of the Fragment's View.

open ViewModelStore

Returns the ViewModelStore associated with this Fragment

Int

Subclasses can not override hashCode().

open static Fragment
instantiate(@NonNull context: Context, @NonNull fname: String)

Like instantiate(Context, String, Bundle) but with a null argument Bundle.

open static Fragment
instantiate(@NonNull context: Context, @NonNull fname: String, @Nullable args: Bundle?)

Create a new instance of a Fragment with the given class name.

Boolean

Return true if the fragment is currently added to its activity.

Boolean

Return true if the fragment has been explicitly detached from the UI.

Boolean

Return true if the fragment has been hidden.

Boolean

Return true if the layout is included as part of an activity view hierarchy via the <fragment> tag.

Boolean

Return true if this fragment is currently being removed from its activity.

Boolean

Return true if the fragment is in the resumed state.

Boolean

Returns true if this fragment is added and its state has already been saved by its host.

Boolean

Return true if the fragment is currently visible to the user.

open Unit
onActivityCreated(@Nullable savedInstanceState: Bundle?)

Called when the fragment's activity has been created and this fragment's view hierarchy instantiated.

open Unit
onActivityResult(requestCode: Int, resultCode: Int, @Nullable data: Intent?)

Receive the result from a previous call to startActivityForResult(Intent, int).

open Unit
onAttach(@NonNull context: Context)

Called when a fragment is first attached to its context.

open Unit
onAttach(@NonNull activity: Activity)

Called when a fragment is first attached to its activity.

open Unit
onAttachFragment(@NonNull childFragment: Fragment)

Called when a fragment is attached as a child of this fragment.

open Unit

open Boolean

This hook is called whenever an item in a context menu is selected.

open Unit
onCreate(@Nullable savedInstanceState: Bundle?)

Called to do initial creation of a fragment.

open Animation?
onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int)

Called when a fragment loads an animation.

open Animator?
onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int)

Called when a fragment loads an animator.

open Unit
onCreateContextMenu(@NonNull menu: ContextMenu, @NonNull v: View, @Nullable menuInfo: ContextMenuInfo?)

Called when a context menu for the view is about to be shown.

open Unit
onCreateOptionsMenu(@NonNull menu: Menu, @NonNull inflater: MenuInflater)

Initialize the contents of the Fragment host's standard options menu.

open View?
onCreateView(@NonNull inflater: LayoutInflater, @Nullable container: ViewGroup?, @Nullable savedInstanceState: Bundle?)

Called to have the fragment instantiate its user interface view.

open Unit

Called when the fragment is no longer in use.

open Unit

Called when this fragment's option menu items are no longer being included in the overall option