Search code examples
javaandroidandroid-preferences

"In-place" EditTextPreference


I used the XML syntax to create a PreferenceActivity with a PreferenceScreen. I added an EditTextPreference and noticed that this renders as a dialog. Is there a way to make the EditText in-place i.e., the text field is displayed right in the PreferenceScreen instead of popping up as a dialog?


Solution

  • In case anyone comes across the same problem, this cannot be accomplished with the built-in Preference classes, but you can subclass Preference, and override getView() to return a ViewGroup containing an in-line EditText (or simply the EditText itself).

    You could probably achieve this by providing the android:layout attribute in the XML too (although I haven't tried this).

    EDIT:
    I tried the android:layout approach above, and it works pretty well.