EditTextPreference
class EditTextPreference : DialogPreference
| kotlin.Any | |||
| ↳ | androidx.preference.Preference | ||
| ↳ | androidx.preference.DialogPreference | ||
| ↳ | androidx.preference.EditTextPreference |
A DialogPreference that shows a EditText in the dialog.
This preference saves a string value.
Summary
Nested types |
|---|
|
Interface definition for a callback to be invoked when the corresponding dialog view for this preference is bound. |
|
A simple |
Public constructors |
|---|
EditTextPreference(context: Context) |
EditTextPreference(context: Context, attrs: AttributeSet?) |
EditTextPreference( |
EditTextPreference( |
Public functions |
|
|---|---|
String? |
getText()Gets the text from the current data storage. |
Unit |
setOnBindEditTextListener(Set an |
Unit |
Saves the text to the current data storage. |
Boolean |
Checks whether this preference's dependents should currently be disabled. |
Protected functions |
|
|---|---|
Any! |
onGetDefaultValue(a: TypedArray, index: Int)Called when a preference is being inflated and the default value attribute needs to be read. |
Unit |
onRestoreInstanceState(state: Parcelable?)Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by |
Parcelable? |
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. |
Unit |
onSetInitialValue(defaultValue: Any!)Implement this to set the initial value of the preference. |
Inherited Constants |
||
|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
EditTextPreference
EditTextPreference(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int
)
EditTextPreference
EditTextPreference(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
)
Public functions
getText
fun getText(): String?
Gets the text from the current data storage.
| Returns | |
|---|---|
String? |
The current preference value |
setOnBindEditTextListener
fun setOnBindEditTextListener(
onBindEditTextListener: EditTextPreference.OnBindEditTextListener?
): Unit
Set an OnBindEditTextListener that will be invoked when the corresponding dialog view for this preference is bound. Set null to remove the existing OnBindEditTextListener.
| Parameters | |
|---|---|
onBindEditTextListener: EditTextPreference.OnBindEditTextListener? |
The |
setText
fun setText(text: String?): Unit
Saves the text to the current data storage.
| Parameters | |
|---|---|
text: String? |
The text to save |
shouldDisableDependents
fun shouldDisableDependents(): Boolean
Checks whether this preference's dependents should currently be disabled.
| Returns | |
|---|---|
Boolean |
|
Protected functions
onGetDefaultValue
protected fun onGetDefaultValue(a: TypedArray, index: Int): Any!
Called when a preference is being inflated and the default value attribute needs to be read. Since different preference types have different value types, the subclass should get and return the default value which will be its value type.
For example, if the value type is String, the body of the method would proxy to getString.
| Parameters | |
|---|---|
a: TypedArray |
The set of attributes |
index: Int |
The index of the default value attribute |
| Returns | |
|---|---|
Any! |
The default value of this preference type |
onRestoreInstanceState
protected fun onRestoreInstanceState(state: Parcelable?): Unit
Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState. This function will never be called with a null state.
| Parameters | |
|---|---|
state: Parcelable? |
The saved state that had previously been returned by |
| See also | |
|---|---|
onSaveInstanceState |
|
restoreHierarchyState |
onSaveInstanceState
protected fun onSaveInstanceState(): Parcelable?
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. This state should only contain information that is not persistent or can be reconstructed later.
| Returns | |
|---|---|
Parcelable? |
A Parcelable object containing the current dynamic state of this preference, or |
| See also | |
|---|---|
onRestoreInstanceState |
|
saveHierarchyState |
onSetInitialValue
protected fun onSetInitialValue(defaultValue: Any!): Unit
Implement this to set the initial value of the preference.
If you are persisting values to SharedPreferences or a PreferenceDataStore you should restore the saved value for the preference.
If you are not persisting values, or there is no value saved for the preference, you should set the value of the preference to defaultValue.
| Parameters | |
|---|---|
defaultValue: Any! |
The default value for the preference if set, otherwise |