Android – how about a password line

I need to programmatically set EditText to display text such as password, and I also need to use this EditText as a single line

I know how to make EditText display password text:

editText.setTransformationMethod(PasswordTransformationMethod.getInstance());

I also know how to display EditText on a single line:

editText.setEllipsize(TruncateAt.END);
editText.setSingleLine();

I don't know how to combine the two. When I put these lines of code together, EditText doesn't work properly. It can't even display the software keyboard

Do any of you know how to solve my problem? Thank you for your reply

resolvent:

I finally did it. For those who have the same problem, the right way is to combine the two requests together, but the order is different from my previous order. So you should do this:

editText.setEllipsize(TruncateAt.END);
editText.setSingleLine();
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());

I hope it will help someone

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>