Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何从Android文本首选项中接受多个值?_Xml_Android Layout_Android Preferences_Edittextpreference - Fatal编程技术网

Xml 如何从Android文本首选项中接受多个值?

Xml 如何从Android文本首选项中接受多个值?,xml,android-layout,android-preferences,edittextpreference,Xml,Android Layout,Android Preferences,Edittextpreference,下面是我用来从文本首选项接受用户名和密码的代码。问题是我必须先接受用户名,然后保存密码。有没有更简单的方法可以一次点击同时接受用户名和密码。单击“用户信息”并同时接收时,可能会出现两个文本字段 EditTextPreferences设计为一次只接收一个字符串。所以你不能同时输入用户名和密码(除非你愿意做一些事情,比如让用户以特定的方式输入,然后解析,这有点荒谬)。另一种方法是简单地使用自定义首选项,并使其通过两个EditText输入两个字符串。然而,底线是使用一个首选项来更改两个设置是不直观

下面是我用来从文本首选项接受用户名和密码的代码。问题是我必须先接受用户名,然后保存密码。有没有更简单的方法可以一次点击同时接受用户名和密码。单击“用户信息”并同时接收时,可能会出现两个文本字段



EditTextPreferences设计为一次只接收一个字符串。所以你不能同时输入用户名和密码(除非你愿意做一些事情,比如让用户以特定的方式输入,然后解析,这有点荒谬)。另一种方法是简单地使用自定义首选项,并使其通过两个EditText输入两个字符串。然而,底线是使用一个首选项来更改两个设置是不直观的。(我希望这本书读起来不会太长)

<EditTextPreference
    android:key="username"
    android:title="@string/pref_title_username"
    android:defaultValue="@string/pref_default_username"
    android:selectAllOnFocus="true"
    android:inputType="textCapWords"
    android:capitalize="words"
    android:singleLine="true"
    android:maxLines="1" />

<EditTextPreference
    android:key="password"
    android:title="@string/pref_title_password"
    android:defaultValue="@string/pref_default_password"
    android:selectAllOnFocus="true"
    android:inputType="textPassword"
    android:capitalize="words"
    android:singleLine="true"
    android:maxLines="1" />