-
Couldn't load subscription status.
- Fork 19
04 EditTextPreference
The class EditTextPreference provides an implementation of a preference, whose behavior is equal to the Android SDK's built-in preference EditTextPreference. Its purpose is to provide a preference, which allows to enter a text within the dialog, which is shown when the preference is clicked. Additionaly it is possible to validate the text, which has been entered by using the preference. For further information about how to achieve such a validation, refer to the section "Validating preferences".
When an EditTextPreference is instantiated programmatically, the following getter and setter method can be used to retrieve or set the preference's current value. Like all preferences, which are provided by this library, the class is extended from the class DialogPreference and therefore the methods of this base class, which have been already discussed, are also available.
| Getter and setter methods | Description | Default value | Restrictions |
|---|---|---|---|
getText():String setText(String):void
|
Returns or sets the currently persisted text of the preference. If a text is set, it is instantly persisted. | null |
none |
getHint():CharSequence setHint(CharSequence):void setHint(int):void
|
Returns or sets the hint of the EditText widget, which is contained by the preference's dialog. |
null |
If the hint is specified as a resource ID, the resource ID must correspond to a valid string resource |
If the preference's default value should be specified by using XML attributes, the following attribute can be used. For customizing the appearance of the preference's dialog, the attributes, which have already been discussed, can be used.
| XML attribute | Description | Format |
|---|---|---|
android:defaultValue |
The preference's default text. | string |
android:hint |
The hint of the EditText widget, which is contained by the preference's dialog. | string |