Android的:如何在编辑文本设置密码的财产? [英] Android: How to set password property in an edit text?

查看:125
本文介绍了Android的:如何在编辑文本设置密码的财产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用用户名密码字段和两个按钮的登录创建登录表单和取消在我的Andr​​oid应用程序。

我使用与的EditText里面,一个警告对话框。

这是在code我用来创建密码的EditText。

 最后的EditText密码=新的EditText(本);
     Password.setGravity(Gravity.CENTER);
     Password.setHint(密码);
     Password.setWidth(200);

     Password.setTransformationMethod(新PasswordTransformationMethod());
     login_alert.addView(密码);
 

我的问题是,纯文本显示,而不是点当我打开一个softkeypad编辑密码。 (它被显示为点,不用时softkeypad模式)

任何人都可以提出一个解决方案吗?

解决方案

  Password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
 

这一次为我工作。
但是,你必须看看屋大维Damiean的评论,他是对的。

I need to create a login form with 'username' 'password' fields and two buttons 'login' and 'cancel' in my android application.

I am using an alert dialog with edittext inside that.

This is the code I used to create password edittext..

     final EditText Password = new EditText(this);
     Password.setGravity(Gravity.CENTER);
     Password.setHint("Password");
     Password.setWidth(200);

     Password.setTransformationMethod(new PasswordTransformationMethod());
     login_alert.addView(Password);

My issue is that, plain text is shown instead of 'dots' when i open a softkeypad to edit the password. (It is shown as dots when not in softkeypad mode)

Can anyone suggest a solution?

解决方案

Password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

This one works for me.
But you have to look at Octavian Damiean's comment, he's right.

这篇关于Android的:如何在编辑文本设置密码的财产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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