Skip to content

Commit ff19c33

Browse files
committed
Add hint
1 parent f54660c commit ff19c33

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Android library: Extensions of AndroidX Preference.
88
<PreferenceScreen>
99
...
1010
<EditTextPreferencePlus
11+
android:hint="hint"
1112
android:inputType="number"
1213
app:formatSummary="true"
1314
app:key="edittext"

demo/src/main/res/xml/settings_preferences.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto">
44
<EditTextPreferencePlus
5+
android:hint="hint"
56
android:inputType="number"
67
app:dialogMessage="dialogMessage"
78
app:formatSummary="true"

edittext/src/main/kotlin/androidx/preference/EditTextPreferencePlus.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class EditTextPreferencePlus @JvmOverloads constructor(
2525
private var mSummary: CharSequence?
2626
var formatSummary: Boolean
2727
var inputType: Int
28+
var hint: CharSequence?
29+
2830
override fun getSummary(): CharSequence? {
2931
val superSummary = super.getSummary()
3032
if (!formatSummary || mSummary == null) {
@@ -54,6 +56,7 @@ class EditTextPreferencePlus @JvmOverloads constructor(
5456
R.styleable.EditTextPreferencePlus_android_inputType,
5557
InputType.TYPE_NULL
5658
)
59+
hint = typedArray.getString(R.styleable.EditTextPreferencePlus_android_hint)
5760
mSummary = typedArray.getString(R.styleable.Preference_summary)
5861
typedArray.recycle()
5962
}

edittext/src/main/kotlin/crazyboyfeng/android/preference/EditTextPreferenceDialogFragmentCompatPlus.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ class EditTextPreferenceDialogFragmentCompatPlus : EditTextPreferenceDialogFragm
1919
val editText = view.findViewById<EditText>(android.R.id.edit)
2020
val editTextPreferencePlus = preference as EditTextPreferencePlus
2121
editText.inputType = editTextPreferencePlus.inputType
22+
editText.hint = editTextPreferencePlus.hint
2223
}
2324
}

edittext/src/main/res/values/attrs.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<resources>
33
<declare-styleable name="EditTextPreferencePlus">
44
<attr name="formatSummary" format="boolean" />
5-
<attr name="android:inputType"/>
5+
<attr name="android:inputType" />
6+
<attr name="android:hint" />
67
</declare-styleable>
78
</resources>

0 commit comments

Comments
 (0)