Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using EditTextPreference with 2 user input fields

Tags:

android

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.

like image 721
Jan S. Avatar asked Feb 03 '10 15:02

Jan S.


1 Answers

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

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.

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"/>
like image 157
Dave Webb Avatar answered Oct 01 '22 18:10

Dave Webb