设置inputType的一个EditText? [英] Set inputType for an EditText?

查看:149
本文介绍了设置inputType的一个EditText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何设置输入类型,一个EditText编程?我想:

How do we set the input type for an EditText programatically? I'm trying:

mEdit.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);

它似乎并没有产生任何影响。

it doesn't seem to have any effect.

感谢

推荐答案

按照 TextView的文档,该方案版本的Andr​​oid:密码是<一个href="http://developer.android.com/reference/android/widget/TextView.html#setTransformationMethod%28android.text.method.TransformationMethod%29">setTransformationMethod(),不setInputType()。所以是这样的:

According to the TextView docs, the programmatic version of android:password is setTransformationMethod(), not setInputType(). So something like:

mEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());

应该做的伎俩。

should do the trick.

这篇关于设置inputType的一个EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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