使用的EditText preference有2个用户输入的字段 [英] Using EditTextPreference with 2 user input fields

查看:244
本文介绍了使用的EditText preference有2个用户输入的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用的EditText preference显示2个输入字段,而不是1。例如,应该显示用户名和密码字段。我不想用一个对话框,为每一个。如何才能做到这一点?在WiFi设置有一个做这个工作,当你想连接到一个受保护的网络,一个对话框,显示设置密码凭证存储有2场。

I would like to use EditTextPreference to show 2 input fields instead of 1. For instance, a username and password field should be shown. I don't want to use a dialog for each one. How can this be done? In the WiFi settings there is one that does this, when you want connect to a protected network, a dialog shows to set a password for the credential storage with 2 fields.

推荐答案

您可以使用<一个href="http://developer.android.com/intl/fr/reference/android/$p$pference/Dialog$p$pference.html"><$c$c>Dialog$p$pference并创建自己的布局,你需要输入字段。

You can use a DialogPreference and create your own layout for the input fields you require.

对话preference 摘要所以你需要创建自己的它的子类,添加的实施<一href="http://developer.android.com/reference/android/$p$pference/Dialog$p$pference.html#onDialogClosed%28boolean%29"><$c$c>onDialogClosed()从对话框,preferences保存价值。

DialogPreference is abstract so you'll need to create your own subclass of it, adding an implementation of onDialogClosed() to save the values from the dialog as Preferences.

您仍然可以通过使用类的XML标记参考自己的类以preferences XML文件。例如:

You can still reference your own class in a Preferences XML file by using the class as the XML tag. For example:

<com.yourdomain.YourDialogPreference
    android:title="Title"
    android:summary="Summary"
    android:key="dialog_preference"/>

这篇关于使用的EditText preference有2个用户输入的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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