Preference Preference Class


Represents the basic Preference UI building block displayed by a PreferenceActivity in the form of a ListView.

[Android.Runtime.Register("android/preference/Preference", ApiSince=1, DoNotGenerateAcw=true)]
public class Preference : Java.Lang.Object, IDisposable, Java.Lang.IComparable
type Preference = class
    inherit Object
    interface IComparable
    interface IJavaObject
    interface IDisposable


Android platform documentation

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.


Preference(Context) Preference(Context)

Constructor to create a Preference.

Preference(Context, IAttributeSet) Preference(Context, IAttributeSet)

Constructor that is called when inflating a Preference from XML.

Preference(Context, IAttributeSet, Int32) Preference(Context, IAttributeSet, Int32)

Perform inflation from XML and apply a class-specific base style.

Preference(Context, IAttributeSet, Int32, Int32) Preference(Context, IAttributeSet, Int32, Int32)

Perform inflation from XML and apply a class-specific base style.

Preference(IntPtr, JniHandleOwnership) Preference(IntPtr, JniHandleOwnership)

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


DefaultOrder DefaultOrder

Specify for Order if a specific order is not required.


Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
Context Context

Returns the Context of this Preference.

Dependency Dependency

Returns the key of the dependency on this Preference.

Editor Editor

Returns an ISharedPreferencesEditor where this Preference can save its value(s).

Enabled Enabled

Checks whether this Preference should be enabled in the list.

Extras Extras

Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one.

Fragment Fragment

Return the fragment class name associated with this Preference.

Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
HasKey HasKey

Checks whether this Preference has a valid key.

Icon Icon

Returns the icon of this Preference.

IconSpaceReserved IconSpaceReserved
IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
Intent Intent

Return the Intent associated with this Preference.

JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
Key Key

Gets the key for this Preference, which is also the key used for storing values into SharedPreferences.

LayoutResource LayoutResource

Gets the layout resource that will be shown as the View for this Preference.

OnPreferenceChangeListener OnPreferenceChangeListener

Returns the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).

OnPreferenceClickListener OnPreferenceClickListener

Returns the callback to be invoked when this Preference is clicked.

Order Order

Gets the order of this Preference with respect to other Preference objects on the same level.

Parent Parent
PeerReference PeerReference Inherited from Object
Persistent Persistent

Checks whether this Preference is persistent.

PreferenceDataStore PreferenceDataStore
PreferenceManager PreferenceManager

Gets the PreferenceManager that manages this Preference object's tree.

RecycleEnabled RecycleEnabled
Selectable Selectable

Checks whether this Preference should be selectable in the list.

SharedPreferences SharedPreferences

Returns the ISharedPreferences where this Preference can read its value(s).

ShouldDisableView ShouldDisableView

Checks whether this Preference should disable its view when it's action is disabled.

SingleLineTitle SingleLineTitle
Summary Summary
SummaryFormatted SummaryFormatted

Returns the summary of this Preference.

ThresholdClass ThresholdClass

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

ThresholdType ThresholdType

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

Title Title
TitleFormatted TitleFormatted

Returns the title of this Preference.

TitleRes TitleRes

Returns the title resource ID of this Preference.

WidgetLayoutResource WidgetLayoutResource

Gets the layout resource for the controllable widget portion of this Preference.


CallChangeListener(Object) CallChangeListener(Object)

Call this method after the user changes the preference, but before the internal state is set.

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
CompareTo(Preference) CompareTo(Preference)

Compares Preference objects based on order (if set), otherwise alphabetically on the titles.

Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
FindPreferenceInHierarchy(String) FindPreferenceInHierarchy(String)

Finds a Preference in this hierarchy (the whole thing, even above/below your PreferenceScreen screen break) with the given key.

GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
GetPersistedBoolean(Boolean) GetPersistedBoolean(Boolean)

Attempts to get a persisted boolean from the ISharedPreferences.

GetPersistedFloat(Single) GetPersistedFloat(Single)

Attempts to get a persisted float from the ISharedPreferences.

GetPersistedInt(Int32) GetPersistedInt(Int32)

Attempts to get a persisted int from the ISharedPreferences.

GetPersistedLong(Int64) GetPersistedLong(Int64)

Attempts to get a persisted long from the ISharedPreferences.

GetPersistedString(String) GetPersistedString(String)

Attempts to get a persisted String from the ISharedPreferences.

GetPersistedStringSet(ICollection<String>) GetPersistedStringSet(ICollection<String>)
GetView(View, ViewGroup) GetView(View, ViewGroup)

Gets the View that will be shown in the PreferenceActivity.

JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyChanged() NotifyChanged()

Should be called when the data of this Preference has changed.

NotifyDependencyChange(Boolean) NotifyDependencyChange(Boolean)

Notifies any listening dependents of a change that affects the dependency.

NotifyHierarchyChanged() NotifyHierarchyChanged()

Should be called when a Preference has been added/removed from this group, or the ordering should be re-evaluated.

OnAttachedToActivity() OnAttachedToActivity()

Called when the Preference hierarchy has been attached to the PreferenceActivity.

OnAttachedToHierarchy(PreferenceManager) OnAttachedToHierarchy(PreferenceManager)

Called when this Preference has been attached to a Preference hierarchy.

OnBindView(View) OnBindView(View)

Binds the created View to the data for this Preference.

OnClick() OnClick()

Processes a click on the preference.

OnCreateView(ViewGroup) OnCreateView(ViewGroup)

Creates the View to be shown for this Preference in the PreferenceActivity.

OnDependencyChanged(Preference, Boolean) OnDependencyChanged(Preference, Boolean)

Called when the dependency changes.

OnGetDefaultValue(TypedArray, Int32) OnGetDefaultValue(TypedArray, Int32)

Called when a Preference is being inflated and the default value attribute needs to be read.

OnParentChanged(Preference, Boolean) OnParentChanged(Preference, Boolean)

Called when the implicit parent dependency changes.

OnPrepareForRemoval() OnPrepareForRemoval()

Called when this Preference is being removed from the hierarchy.

OnRestoreInstanceState(IParcelable) OnRestoreInstanceState(IParcelable)

Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by OnSaveInstanceState().

OnSaveInstanceState() OnSaveInstanceState()

Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state.

OnSetInitialValue(Boolean, Object) OnSetInitialValue(Boolean, Object)

Implement this to set the initial value of the Preference.

PeekExtras() PeekExtras()

Return the extras Bundle object associated with this preference, returning null if there is not currently one.

PersistBoolean(Boolean) PersistBoolean(Boolean)

Attempts to persist a boolean to the ISharedPreferences.

PersistFloat(Single) PersistFloat(Single)

Attempts to persist a float to the ISharedPreferences.

PersistInt(Int32) PersistInt(Int32)

Attempts to persist an int to the ISharedPreferences.

PersistLong(Int64) PersistLong(Int64)

Attempts to persist a long to the ISharedPreferences.

PersistString(String) PersistString(String)

Attempts to persist a String to the ISharedPreferences.

PersistStringSet(ICollection<String>) PersistStringSet(ICollection<String>)
RestoreHierarchyState(Bundle) RestoreHierarchyState(Bundle)

Restore this Preference hierarchy's previously saved state from the given container.

SaveHierarchyState(Bundle) SaveHierarchyState(Bundle)

Store this Preference hierarchy's frozen state into the given container.

SetDefaultValue(Object) SetDefaultValue(Object)

Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.

SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetIcon(Int32) SetIcon(Int32)

Sets the icon for this Preference with a resource ID.

SetSummary(Int32) SetSummary(Int32)

Sets the summary for this Preference with a resource ID.

SetTitle(Int32) SetTitle(Int32)

Sets the title for this Preference with a resource ID.

ShouldCommit() ShouldCommit()

Returns whether the Preference should commit its saved value(s) in Editor.

ShouldDisableDependents() ShouldDisableDependents()

Checks whether this preference's dependents should currently be disabled.

ShouldPersist() ShouldPersist()

Checks whether, at the given time this method is called, this Preference should store/restore its value(s) into the ISharedPreferences.

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

Returns a string containing a concise, human-readable description of this object.

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

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)


PreferenceChange PreferenceChange
PreferenceClick PreferenceClick

Explicit Interface Implementations

IComparable.CompareTo(Object) IComparable.CompareTo(Object)
IJavaObjectEx.ToLocalJniHandle() IJavaObjectEx.ToLocalJniHandle() Inherited from Object
IJavaPeerable.Disposed() IJavaPeerable.Disposed() Inherited from Object
IJavaPeerable.DisposeUnlessReferenced() IJavaPeerable.DisposeUnlessReferenced() Inherited from Object
IJavaPeerable.Finalized() IJavaPeerable.Finalized() Inherited from Object
IJavaPeerable.SetJniIdentityHashCode(Int32) IJavaPeerable.SetJniIdentityHashCode(Int32) Inherited from Object
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) Inherited from Object
IJavaPeerable.SetPeerReference(JniObjectReference) IJavaPeerable.SetPeerReference(JniObjectReference) Inherited from Object

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to