设置inputType的一个EditText?inputType、EditText

2023-09-12 00:45:09 作者:你若安好那还得了

我们如何设置输入类型,一个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:密码是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.

 
精彩推荐
图片推荐