0

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?

curioustechizen
  • 10,572
  • 10
  • 61
  • 110

2 Answers2

3

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.

curioustechizen
  • 10,572
  • 10
  • 61
  • 110
1

add android:layout="@layout/your_loyout".

where your_layout.xml is like

<EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" />

Unihedron
  • 10,902
  • 13
  • 62
  • 72
AmAn yAdAv
  • 31
  • 3