[英]“In-place” EditTextPreference
I used the XML syntax to create a PreferenceActivity
with a PreferenceScreen
. 我使用XML语法来创建带有
PreferenceActivity
的PreferenceScreen
。 I added an EditTextPreference
and noticed that this renders as a dialog. 我添加了一个
EditTextPreference
并注意到它呈现为对话框。 Is there a way to make the EditText
in-place ie, the text field is displayed right in the PreferenceScreen
instead of popping up as a dialog? 有没有一种方法可以使
EditText
就位,即文本字段直接显示在PreferenceScreen
而不是作为对话框弹出?
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). 如果有人遇到相同的问题,则无法使用内置的Preference类来完成此操作,但是您可以将
Preference
子类化,并重写getView()
以返回包含EditText
的ViewGroup
(或简单地称为EditText
本身)。
You could probably achieve this by providing the android:layout
attribute in the XML too (although I haven't tried this). 您也可以通过在XML中提供
android:layout
属性来实现此目的(尽管我还没有尝试过)。
EDIT: 编辑:
I tried the android:layout
approach above, and it works pretty well. 我尝试了上面的
android:layout
方法,效果很好。
add android:layout="@layout/your_loyout". 添加android:layout =“ @ layout / your_loyout”。
where your_layout.xml
is like your_layout.xml
就像
<EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.