语言

Preference 构造函数

定义

重载

名称 说明
Preference(Context)

用于创建首选项的构造函数。

Preference(Context, IAttributeSet)

从 XML 扩充首选项时调用的构造函数。

Preference(IntPtr, JniHandleOwnership)

创建 JNI 对象的托管表示形式时使用的构造函数;由运行时调用。

Preference(Context, IAttributeSet, Int32)

从 XML 执行通货膨胀并应用特定于类的基样式。

Preference(Context, IAttributeSet, Int32, Int32)

从 XML 执行通货膨胀并应用特定于类的基样式。

Preference(Context)

用于创建首选项的构造函数。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")]
public Preference(Android.Content.Context? context);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")>]
new Android.Preferences.Preference : Android.Content.Context -> Android.Preferences.Preference

参数

context
Context

要在其中存储首选项值的上下文。

特性

注解

用于创建首选项的构造函数。

Java文档android.preference.Preference.Preference(android.content.Context)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

Preference(Context, IAttributeSet)

从 XML 扩充首选项时调用的构造函数。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "")]
public Preference(Android.Content.Context? context, Android.Util.IAttributeSet? attrs);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "")>]
new Android.Preferences.Preference : Android.Content.Context * Android.Util.IAttributeSet -> Android.Preferences.Preference

参数

context
Context

与之关联的上下文,可通过该上下文访问当前主题、资源 SharedPreferences等。

attrs
IAttributeSet

正在膨胀首选项的 XML 标记的属性。

特性

注解

从 XML 扩充首选项时调用的构造函数。 当从 XML 文件构造首选项时,会调用此方法,并提供在 XML 文件中指定的属性。 此版本使用默认样式 0,因此应用的唯一属性值是上下文的主题和给定 AttributeSet 中的属性值。

Java文档android.preference.Preference.Preference(android.content.Context, android.util.AttributeSet)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

另请参阅

  • <xref:Android.Preferences.Preference(Android.Content.Context%2c+Android.Util.IAttributeSet%2c+Android.Util.IAttributeSet)>

适用于

Preference(IntPtr, JniHandleOwnership)

创建 JNI 对象的托管表示形式时使用的构造函数;由运行时调用。

protected Preference(IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.Preferences.Preference : nativeint * Android.Runtime.JniHandleOwnership -> Android.Preferences.Preference

参数

javaReference
IntPtr

nativeint

IntPtr一个包含Java本机接口 (JNI) 对象引用。

transfer
JniHandleOwnership

指示 JniHandleOwnership如何处理 javaReference

注解

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

Preference(Context, IAttributeSet, Int32)

从 XML 执行通货膨胀并应用特定于类的基样式。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "")]
public Preference(Android.Content.Context? context, Android.Util.IAttributeSet? attrs, int defStyleAttr);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "")>]
new Android.Preferences.Preference : Android.Content.Context * Android.Util.IAttributeSet * int -> Android.Preferences.Preference

参数

context
Context

与之关联的上下文,可通过该上下文访问当前主题、资源 SharedPreferences等。

attrs
IAttributeSet

正在膨胀首选项的 XML 标记的属性。

defStyleAttr
Int32

当前主题中的一个属性,该属性包含对样式资源的引用,该资源提供视图的默认值。 可以是 0,无法查找默认值。

特性

注解

从 XML 执行通货膨胀并应用特定于类的基样式。 首选项的此构造函数允许子类在膨胀时使用自己的基样式。 例如,CheckBoxPreference构造函数调用此版本的超级类构造函数并为 defStyleAttr 提供android.R.attr.checkBoxPreferenceStyle。 这允许主题的复选框首选项样式修改所有基本首选项属性以及 CheckBoxPreference 类的属性。

Java文档android.preference.Preference.Preference(android.content.Context, android.util.AttributeSet, int)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

另请参阅

  • <xref:Android.Preferences.Preference(Android.Content.Context%2c+Android.Util.IAttributeSet)>

适用于

Preference(Context, IAttributeSet, Int32, Int32)

从 XML 执行通货膨胀并应用特定于类的基样式。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "")]
public Preference(Android.Content.Context? context, Android.Util.IAttributeSet? attrs, int defStyleAttr, int defStyleRes);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "")>]
new Android.Preferences.Preference : Android.Content.Context * Android.Util.IAttributeSet * int * int -> Android.Preferences.Preference

参数

context
Context

与之关联的上下文,可通过该上下文访问当前主题、资源 SharedPreferences等。

attrs
IAttributeSet

正在膨胀首选项的 XML 标记的属性。

defStyleAttr
Int32

当前主题中的一个属性,该属性包含对样式资源的引用,该资源提供视图的默认值。 可以是 0,无法查找默认值。

defStyleRes
Int32

样式资源的资源标识符,它提供视图的默认值,仅当 defStyleAttr 为 0 或无法在主题中找到时才使用。 可以是 0,无法查找默认值。

特性

注解

从 XML 执行通货膨胀并应用特定于类的基样式。 首选项的此构造函数允许子类在膨胀时使用自己的基样式。 例如,CheckBoxPreference构造函数调用此版本的超级类构造函数并为 defStyleAttr 提供android.R.attr.checkBoxPreferenceStyle。 这允许主题的复选框首选项样式修改所有基本首选项属性以及 CheckBoxPreference 类的属性。

Java文档android.preference.Preference.Preference(android.content.Context, android.util.AttributeSet, int, int)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

另请参阅

  • <xref:Android.Preferences.Preference(Android.Content.Context%2c+Android.Util.IAttributeSet)>

适用于