共用方式為


PreferenceFragment Class

Definition

Shows a hierarchy of Preference objects as lists.

[Android.Runtime.Register("android/preference/PreferenceFragment", DoNotGenerateAcw=true)]
public abstract class PreferenceFragment : Android.App.Fragment
[<Android.Runtime.Register("android/preference/PreferenceFragment", DoNotGenerateAcw=true)>]
type PreferenceFragment = class
    inherit Fragment
Inheritance
PreferenceFragment
Attributes

Remarks

Shows a hierarchy of Preference objects as lists. These preferences will automatically save to SharedPreferences as the user interacts with them. To retrieve an instance of SharedPreferences that the preference hierarchy in this fragment will use, call PreferenceManager#getDefaultSharedPreferences(android.content.Context) with a context in the same package as this fragment.

Furthermore, the preferences shown will follow the visual style of system preferences. It is easy to create a hierarchy of preferences (that can be shown on multiple screens) via XML. For these reasons, it is recommended to use this fragment (as a superclass) to deal with preferences in applications.

A PreferenceScreen object should be at the top of the preference hierarchy. Furthermore, subsequent PreferenceScreen in the hierarchy denote a screen break--that is the preferences contained within subsequent PreferenceScreen should be shown on another screen. The preference framework handles showing these other screens from the preference hierarchy.

The preference hierarchy can be formed in multiple ways: <li> From an XML file specifying the hierarchy <li> From different Activity Activities that each specify its own preferences in an XML file via Activity meta-data <li> From an object hierarchy rooted with PreferenceScreen

To inflate from XML, use the #addPreferencesFromResource(int). The root element should be a PreferenceScreen. Subsequent elements can point to actual Preference subclasses. As mentioned above, subsequent PreferenceScreen in the hierarchy will result in the screen break.

To specify an Intent to query Activity Activities that each have preferences, use #addPreferencesFromIntent. Each Activity can specify meta-data in the manifest (via the key PreferenceManager#METADATA_KEY_PREFERENCES) that points to an XML resource. These XML resources will be inflated into a single preference hierarchy and shown by this fragment.

To specify an object hierarchy rooted with PreferenceScreen, use #setPreferenceScreen(PreferenceScreen).

As a convenience, this fragment implements a click listener for any preference in the current hierarchy, see #onPreferenceTreeClick(PreferenceScreen, Preference).

<div class="special reference"> <h3>Developer Guides</h3>

For information about using PreferenceFragment, read the Settings guide.

</div>

This member is deprecated. Use the AndroidX Preference Library for consistent behavior across all devices. For more information on using the AndroidX Preference Library see Settings.

Java documentation for android.preference.PreferenceFragment.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

PreferenceFragment()
PreferenceFragment(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Activity

Return the Activity this fragment is currently associated with.

(Inherited from Fragment)
AllowEnterTransitionOverlap

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

(Inherited from Fragment)
AllowReturnTransitionOverlap

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

(Inherited from Fragment)
Arguments

Return the arguments supplied to #setArguments, if any. -or- Supply the construction arguments for this fragment.

(Inherited from Fragment)
ChildFragmentManager

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

(Inherited from Fragment)
Class

Returns the runtime class of this Object.

(Inherited from Object)
Context

Return the Context this fragment is currently associated with.

(Inherited from Fragment)
EnterTransition

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

(Inherited from Fragment)
ExitTransition

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. -or- Sets 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.

(Inherited from Fragment)
FragmentManager

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

(Inherited from Fragment)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
Host

Return the host object of this fragment.

(Inherited from Fragment)
Id

Return the identifier this fragment is known by.

(Inherited from Fragment)
IsAdded

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

(Inherited from Fragment)
IsDetached

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

(Inherited from Fragment)
IsHidden

Return true if the fragment has been hidden.

(Inherited from Fragment)
IsInLayout

Return true if the layout is included as part of an activity view hierarchy via the &lt;fragment&gt; tag.

(Inherited from Fragment)
IsRemoving

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

(Inherited from Fragment)
IsResumed

Return true if the fragment is in the resumed state.

(Inherited from Fragment)
IsStateSaved

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

(Inherited from Fragment)
IsVisible

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

(Inherited from Fragment)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
LayoutInflater

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

(Inherited from Fragment)
LoaderManager

Return the LoaderManager for this fragment, creating it if needed.

(Inherited from Fragment)
ParentFragment

Returns the parent Fragment containing this Fragment.

(Inherited from Fragment)
PeerReference (Inherited from Object)
PreferenceManager

Returns the PreferenceManager used by this fragment.

PreferenceScreen

Gets the root of the preference hierarchy that this fragment is showing. -or- Sets the root of the preference hierarchy that this fragment is showing.

ReenterTransition

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

(Inherited from Fragment)
Resources

Return getActivity().getResources().

(Inherited from Fragment)
RetainInstance

Control whether a fragment instance is retained across Activity re-creation (such as from a configuration change).

(Inherited from Fragment)
ReturnTransition

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. -or- Sets 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.

(Inherited from Fragment)
SharedElementEnterTransition

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

(Inherited from Fragment)
SharedElementReturnTransition

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

(Inherited from Fragment)
Tag

Get the tag name of the fragment, if specified.

(Inherited from Fragment)
TargetFragment

Return the target fragment set by #setTargetFragment.

(Inherited from Fragment)
TargetRequestCode

Return the target request code set by #setTargetFragment.

(Inherited from Fragment)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

UserVisibleHint

Set a hint to the system about whether this fragment's UI is currently visible to the user.

(Inherited from Fragment)
View

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

(Inherited from Fragment)

Methods

AddPreferencesFromIntent(Intent)

Adds preferences from activities that match the given Intent.

AddPreferencesFromResource(Int32)

Inflates the given XML resource and adds the preference hierarchy to the current preference hierarchy.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Dump(String, FileDescriptor, PrintWriter, String[])

Print the Fragments's state into the given stream.

(Inherited from Fragment)
Equals(Object)
Obsolete.

Subclasses can not override equals().

(Inherited from Fragment)
FindPreference(ICharSequence)

Finds a Preference based on its key.

FindPreference(String)

Finds a Preference based on its key.

GetHashCode()
Obsolete.

Subclasses can not override hashCode().

(Inherited from Fragment)
GetString(Int32, Object[])

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

(Inherited from Fragment)
GetString(Int32)

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

(Inherited from Fragment)
GetText(Int32)

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

(Inherited from Fragment)
GetTextFormatted(Int32)

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

(Inherited from Fragment)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
OnActivityCreated(Bundle)

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

(Inherited from Fragment)
OnActivityResult(Int32, Result, Intent)

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

(Inherited from Fragment)
OnAttach(Activity)

This member is deprecated.

(Inherited from Fragment)
OnAttach(Context)

Called when a fragment is first attached to its context.

(Inherited from Fragment)
OnAttachFragment(Fragment)

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

(Inherited from Fragment)
OnConfigurationChanged(Configuration)

Called by the system when the device configuration changes while your component is running.

(Inherited from Fragment)
OnContextItemSelected(IMenuItem)

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

(Inherited from Fragment)
OnCreate(Bundle)

Called to do initial creation of a fragment.

(Inherited from Fragment)
OnCreateAnimator(FragmentTransit, Boolean, Int32)

Called when a fragment loads an animation.

(Inherited from Fragment)
OnCreateContextMenu(IContextMenu, View, IContextMenuContextMenuInfo)

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

(Inherited from Fragment)
OnCreateOptionsMenu(IMenu, MenuInflater)

Initialize the contents of the Activity's standard options menu.

(Inherited from Fragment)
OnCreateView(LayoutInflater, ViewGroup, Bundle)

Called to have the fragment instantiate its user interface view.

(Inherited from Fragment)
OnDestroy()

Called when the fragment is no longer in use.

(Inherited from Fragment)
OnDestroyOptionsMenu()

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

(Inherited from Fragment)
OnDestroyView()

Called when the view previously created by #onCreateView has been detached from the fragment.

(Inherited from Fragment)
OnDetach()

Called when the fragment is no longer attached to its activity.

(Inherited from Fragment)
OnGetLayoutInflater(Bundle)

Returns the LayoutInflater used to inflate Views of this Fragment.

(Inherited from Fragment)
OnHiddenChanged(Boolean)

Called when the hidden state (as returned by #isHidden() of the fragment has changed.

(Inherited from Fragment)
OnInflate(Activity, IAttributeSet, Bundle)

This member is deprecated.

(Inherited from Fragment)
OnInflate(Context, IAttributeSet, Bundle)

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.

(Inherited from Fragment)
OnInflate(IAttributeSet, Bundle)
Obsolete.

This member is deprecated.

(Inherited from Fragment)
OnLowMemory()

This is called when the overall system is running low on memory, and actively running processes should trim their memory usage.

(Inherited from Fragment)
OnMultiWindowModeChanged(Boolean, Configuration)

Called when the Fragment's activity changes from fullscreen mode to multi-window mode and visa-versa.

(Inherited from Fragment)
OnMultiWindowModeChanged(Boolean)

Called when the Fragment's activity changes from fullscreen mode to multi-window mode and visa-versa.

(Inherited from Fragment)
OnOptionsItemSelected(IMenuItem)

This hook is called whenever an item in your options menu is selected.

(Inherited from Fragment)
OnOptionsMenuClosed(IMenu)

This hook is called whenever the options menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected).

(Inherited from Fragment)
OnPause()

Called when the Fragment is no longer resumed.

(Inherited from Fragment)
OnPictureInPictureModeChanged(Boolean, Configuration)

Called by the system when the activity changes to and from picture-in-picture mode.

(Inherited from Fragment)
OnPictureInPictureModeChanged(Boolean)

Called by the system when the activity changes to and from picture-in-picture mode.

(Inherited from Fragment)
OnPreferenceTreeClick(PreferenceScreen, Preference)

To be added

OnPrepareOptionsMenu(IMenu)

Prepare the Screen's standard options menu to be displayed.

(Inherited from Fragment)
OnRequestPermissionsResult(Int32, String[], Permission[])

Callback for the result from requesting permissions.

(Inherited from Fragment)
OnResume()

Called when the fragment is visible to the user and actively running.

(Inherited from Fragment)
OnSaveInstanceState(Bundle)

Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance of its process is restarted.

(Inherited from Fragment)
OnStart()

Called when the Fragment is visible to the user.

(Inherited from Fragment)
OnStop()

Called when the Fragment is no longer started.

(Inherited from Fragment)
OnTrimMemory(TrimMemory)

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.

(Inherited from Fragment)
OnViewCreated(View, Bundle)

Called immediately after #onCreateView(LayoutInflater, ViewGroup, Bundle) has returned, but before any saved state has been restored in to the view.

(Inherited from Fragment)
OnViewStateRestored(Bundle)

Called when all saved state has been restored into the view hierarchy of the fragment.

(Inherited from Fragment)
PostponeEnterTransition()

Postpone the entering Fragment transition until #startPostponedEnterTransition() or FragmentManager#executePendingTransactions() has been called.

(Inherited from Fragment)
RegisterForContextMenu(View)

Registers a context menu to be shown for the given view (multiple views can show the context menu).

(Inherited from Fragment)
RequestPermissions(String[], Int32)

Requests permissions to be granted to this application.

(Inherited from Fragment)
SetEnterSharedElementCallback(SharedElementCallback)

When custom transitions are used with Fragments, the enter transition callback is called when this Fragment is attached or detached when not popping the back stack.

(Inherited from Fragment)
SetExitSharedElementCallback(SharedElementCallback)

When custom transitions are used with Fragments, the exit transition callback is called when this Fragment is attached or detached when popping the back stack.

(Inherited from Fragment)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetHasOptionsMenu(Boolean)

Report that this fragment would like to participate in populating the options menu by receiving a call to #onCreateOptionsMenu and related methods.

(Inherited from Fragment)
SetInitialSavedState(Fragment+SavedState)

Set the initial saved state that this Fragment should restore itself from when first being constructed, as returned by FragmentManager#saveFragmentInstanceState(Fragment) FragmentManager.saveFragmentInstanceState.

(Inherited from Fragment)
SetMenuVisibility(Boolean)

Set a hint for whether this fragment's menu should be visible.

(Inherited from Fragment)
SetTargetFragment(Fragment, Int32)

Optional target for this fragment.

(Inherited from Fragment)
ShouldShowRequestPermissionRationale(String)

Gets whether you should show UI with rationale before requesting a permission.

(Inherited from Fragment)
StartActivity(Intent, Bundle)

Call Activity#startActivity(Intent, Bundle) from the fragment's containing Activity.

(Inherited from Fragment)
StartActivity(Intent)

Call Activity#startActivity(Intent) from the fragment's containing Activity.

(Inherited from Fragment)
StartActivityForResult(Intent, Int32, Bundle)

Call Activity#startActivityForResult(Intent, int, Bundle) from the fragment's containing Activity.

(Inherited from Fragment)
StartActivityForResult(Intent, Int32)

Call Activity#startActivityForResult(Intent, int) from the fragment's containing Activity.

(Inherited from Fragment)
StartIntentSenderForResult(IntentSender, Int32, Intent, ActivityFlags, ActivityFlags, Int32, Bundle)

Call Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int, Bundle) from the fragment's containing Activity.

(Inherited from Fragment)
StartPostponedEnterTransition()

Begin postponed transitions after #postponeEnterTransition() was called.

(Inherited from Fragment)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterForContextMenu(View)

Prevents a context menu to be shown for the given view.

(Inherited from Fragment)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to