密码单行如何
我需要以编程方式设置 EditText
以显示密码等文本,并且我还需要此 EditText
为单行。
我知道如何使 EditText
显示密码等文本:
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
我也知道如何在单行上显示 EditText
:
editText.setEllipsize(TruncateAt.END);
editText.setSingleLine();
我不知道如何将这两者结合起来。当我将这些代码行放在一起时,EditText
不起作用。即使是软件键盘也无法显示。
你们有人知道如何解决我的问题吗?预先感谢您的回答。
I need to programatically set EditText
to display text like password and I also need this EditText
to be single line.
I know how to make EditText
to display text like password:
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
I also know how to display EditText
on single line:
editText.setEllipsize(TruncateAt.END);
editText.setSingleLine();
I don't know how to combine these two. When I put these lines of code together, the EditText
is not working. Even the software keyboard can't be displayed for it.
Does anyone of you guys know how to solve my problem? Thanks in advance for your answer(s).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我终于做到了。对于那些遇到同样问题的人来说,正确的方法是将两个请求结合起来,但顺序与我之前的顺序不同。所以你应该这样做:
我希望这会对某人有所帮助。
I finally did it. For those who have the same problem the correct approach is to combine the two requests but in the different order than I did it before. So you should do:
I hope this will help someone.
要使
EditText
隐藏密码字符,请将password
属性添加到布局中的相关元素。http://developer.android.com/reference/android/widget /TextView.html#attr_android:password
也可以通过编程方式完成
To make
EditText
conceal password characters, add thepassword
attribute to the relevant element in your layout.http://developer.android.com/reference/android/widget/TextView.html#attr_android:password
It can also be done programmatically
在 XML 文件类型中
In XML file Type