【问题标题】:How to type Non-English text in a password EditText with android:inputType="textPassword"如何使用 android:inputType="textPassword" 在密码 EditText 中键入非英语文本
【发布时间】:2017-01-04 08:12:18
【问题描述】:

我的应用中有一个带有“textPassword”inputType 的 EditText,我尝试设置非英语密码,但 inputType 不允许我选择另一种语言。 也许我的应用用户更喜欢设置波斯语密码。

See The Picture, Please

有什么想法吗?

【问题讨论】:

  • 你试过模式了吗
  • @ozi:不,我没有。我该如何尝试?
  • 我试过了,密码 edittext 接受我的特殊字符 (ü) 你的特殊字符是什么?
  • @ozi:根本不允许我更改语言!!!请看我刚刚在帖子中上传的图片。
  • 请看下面@marmor 的回答,如果你没问题,接受它

标签: java android android-edittext persian non-english


【解决方案1】:

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());

【讨论】:

  • 不,它不起作用。它也不允许我更改语言。无论是否使用 inputType。并且 android:password 已弃用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-20
  • 1970-01-01
  • 2018-11-08
  • 1970-01-01
  • 2015-09-23
  • 2015-06-18
相关资源
最近更新 更多