Preference

constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int)(source)

Perform inflation from XML and apply a class-specific base style. This constructor allows subclasses to use their own base style when they are inflating. For example, a CheckBoxPreference constructor calls this version of the super class constructor and supplies android.R.attr.checkBoxPreferenceStyle for defStyleAttr. This allows the theme's checkbox preference style to modify all of the base preference attributes as well as the CheckBoxPreference class's attributes.

Parameters

context

The Context this is associated with, through which it can access the current theme, resources, SharedPreferences, etc.

attrs

The attributes of the XML tag that is inflating the preference

defStyleAttr

An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

defStyleRes

A resource identifier of a style resource that supplies default values for the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.

See also


constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int)(source)

Perform inflation from XML and apply a class-specific base style. This constructor allows subclasses to use their own base style when they are inflating. For example, a CheckBoxPreference constructor calls this version of the super class constructor and supplies android.R.attr.checkBoxPreferenceStyle for defStyleAttr. This allows the theme's checkbox preference style to modify all of the base preference attributes as well as the CheckBoxPreference class's attributes.

Parameters

context

The Context this is associated with, through which it can access the current theme, resources, SharedPreferences, etc.

attrs

The attributes of the XML tag that is inflating the preference

defStyleAttr

An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

See also


constructor(@NonNull context: Context, @Nullable attrs: AttributeSet)(source)

Constructor that is called when inflating a preference from XML. This is called when a preference is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.

Parameters

context

The Context this is associated with, through which it can access the current theme, resources, SharedPreferences, etc.

attrs

The attributes of the XML tag that is inflating the preference

See also


constructor(@NonNull context: Context)(source)

Constructor to create a preference.

Parameters

context

The Context this is associated with, through which it can access the current theme, resources, SharedPreferences, etc.