android - 在设置中创建 Android 首选项以设置密码

标签 android settings preferences

我想要在首选项中设置一个允许用户创建密码的设置。 Play 商店就是一个完美的例子。在设置中,单击“密码”,会弹出一个对话框,其中包含一个 EditText 字段,其中包含隐藏字符的密码字段。你会怎么做?

我很确定这不是 EditTextPreference。这是自定义偏好吗?你会怎么做这个?我可以获得 XML 部分的示例吗?

最佳答案

I'm pretty sure this is not EditText preference

EditTextPreference 可以工作。引用the documentation :

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

因此,添加 android:password="true" 作为您的首选项 XML 的一部分应该可行。

话虽如此,我们当然欢迎您为此创建自己的自定义 DialogPreference

关于android - 在设置中创建 Android 首选项以设置密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20734639/

相关文章:

iphone - 如何创建首选项 Pane ?

iphone - 在 Settings.app 中隐藏应用程序特定的设置

visual-studio - 无法在 Visual Studio 2013 中更改字体

C# 自定义用户设置类不保存

asp.net - 如何将default.aspx设置为Visual Studio调试器的默认启动点?

java - Android 编辑文本 : Check if whitespace not at beginning or end

c++ - 更多与更少的功能

java - 如何将 MediaMuxer/MediaCodec InputSurface 与 GLSurfaceView 一起使用?

安卓模拟器报错:missing kernel file

php - 从 Eclipse 上的 XAMPP 本地主机获取 JSON 提要