我的应用程序中有一个带有“textPassword”inputType 的 EditText,我尝试设置一个非英语密码,但 inputType 不允许我选择其他语言。 也许我的应用用户更喜欢设置波斯语密码。
有什么想法吗?
最佳答案
inputType
被视为键盘应用程序关于如何处理特定文本字段的提示,即使某些键盘确实允许非英语密码,您也可以不要指望所有键盘应用程序都能像那样工作。
不要使用inputType
,而是将password
字段设置为true
,这会导致字符在屏幕上隐藏,但是将允许您获得任何输入,您可能还应该关闭建议(使用 inputType
字段):
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text|textShortMessage|textNoSuggestions"
android:password="true"/>
更新
您可以创建一个带有一些文本 inputType
的普通 EditText
,只需将字符设置为显示为点而不是纯文本:
EditText passwordView = (EditText) layout.findViewById(R.id.password);
passwordView.setTransformationMethod(PasswordTransformationMethod.getInstance());
关于java - 如何使用android :inputType ="textPassword"在密码EditText中输入非英文文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41459065/