Question

I would like a setting in preferences that allows the user to create a password. The perfect example is in the Play Store. In settings you click on Password and a dialog box pops up with an EditText field with a password field that hides the characters. How would you do that?

I'm pretty sure this is not EditTextPreference. Is this a custom preference? How would you make this? Can I get a sample for the XML part of it?

Était-ce utile?

La solution

I'm pretty sure this is not EditText preference

EditTextPreference would work. Quoting the documentation:

This EditText can be modified either programmatically via getEditText(), or through XML by setting any EditText attributes on the EditTextPreference.

So adding android:password="true" as part of your preference XML should work.

That being said, you are certainly welcome to create your own custom DialogPreference for this.

Autres conseils

Using intents

In some cases, you might want a preference item to open a different activity instead of a settings screen, such as a web browser to view a web page. To invoke an Intent when the user selects a preference item

it's available at android guide, check this link http://developer.android.com/guide/topics/ui/settings.html#Intents

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top