"就地"的EditText preference [英] "In-place" EditTextPreference

查看:159
本文介绍了"就地"的EditText preference的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的XML语法来创建一个 preferenceActivity preferenceScreen 。我添加了一个的EditText preference ,并注意到,这呈现为一个对话框。有没有一种方法,使的EditText 就地即是正确的 preferenceScreen 而不是弹出一个对话框?

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?

推荐答案

在情况下,任何人都遇到同样的问题,这不能用内置的preference类,但是你也可以继承 preference ,并覆盖 getView()返回的ViewGroup 含在线的EditText (或简称的EditText 本身)。

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).

编辑:结果
我试过的android:布局办法以上,它的工作原理pretty以及


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

这篇关于"就地"的EditText preference的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆