Difference between android:inputType=quot;textPasswordquot;, quot;textVisiblePasswordquot;,quot;textWebPasswordquot; and quot;numberPasswordquot; in android?(android:inputType=“textPassword、“textVisiblePassword、“textWebPassword之间的区别和“数字密码在安卓?) - IT屋-程序员软件
问题描述
谁能解释一下两者的区别
Can anyone explain the differences between the
android:inputType="textPassword",
android:inputType="textVisiblePassword",
android:inputType="textWebPassword",
android:inputType="numberPassword"
Android Layout 中的 EditText ViewGroup?
of EditText ViewGroup in Android Layout?
推荐答案
即使已经回答了,我还是会在密码差异方面添加更多细节InputType 变体:
Even though it has been already answered I'll add some more details to the differences in password InputType variations:
android:inputType="textPassword"
:对应TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_PASSWORD
即它允许您输入一个作为密码的字符串(隐藏并防止自动完成和建议,除非明确设置).这个主要用于我们要输入密码的时候.android:inputType="textVisiblePassword"
:对应TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
并且与前一个相同,但密码是可见的(如果您想使用它来允许查看默认密码,因为它会阻止自动完成和建议,除非它们被明确设置 - 这是可取的也有办法隐藏密码)android:inputType="numberPassword"
:对应TYPE_CLASS_NUMBER |TYPE_NUMBER_VARIATION_PASSWORD
与android:inputType="textPassword"
相同,但您只能输入数字.考虑到如果你使用它,密码不会那么强,所以我不建议在处理敏感数据时使用它,除非它与其他类型的用户身份验证一起使用.android:inputType="textWebPassword"
:对应TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_WEB_PASSWORD
并具有与android:inputType="textPassword"
相同的行为,但它旨在用于 Web 表单,即在浏览器页面内(任何从用户).所以这不应在EditText
本机控件中使用.使用此方法的示例是通过包装WebView
在 WebView 中禁用 Android 的 AutoSuggestion并更改EditorInfo
输入类型以在onCreateInputConnection
方法中添加标志InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
.
android:inputType="textPassword"
: Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD
i.e. it allows you to enter a string that is taken as a password (hidden and preventing autocompletion and suggestions unless set explicitly). This one is mostly used when we want to enter passwords.android:inputType="textVisiblePassword"
: Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
and is the same as the previous one but the password is visible (useful if you want to use it to allow to see the password as default because it prevents the autocompletion and suggestions unless they are set explicitly - it is advisable to also have a way to hide the password)android:inputType="numberPassword"
: Corresponds toTYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_PASSWORD
same asandroid:inputType="textPassword"
but you can only enter numbers. Take into account that if you use it the password will not be so strong, so I wouldn't recommend using it when dealing with sensitive data unless it is used along with another type of user authentication.android:inputType="textWebPassword"
: Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_PASSWORD
and has the same behaviour asandroid:inputType="textPassword"
but it is intended to be used in a web form i.e. inside a browser page (any web form control that takes input from a user). So this shall not be used in anEditText
native control. An example of using this would be to disable AutoSuggestion from Android in a WebView by wrapping aWebView
and changingEditorInfo
input type to add the flagInputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
inside theonCreateInputConnection
method.
作为从链接中截取的最后一个示例:
As an example of the last one taken from the link:
public class NoSuggestionsWebView extends WebView {
...
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs)
{
InputConnection ic = super.onCreateInputConnection(outAttrs);
outAttrs.inputType &= ~EditorInfo.TYPE_MASK_VARIATION; /* clear VARIATION type to be able to set new value */
outAttrs.inputType |= InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; /* WEB_PASSWORD type will prevent form suggestions */
return ic;
}
}
我希望现在很清楚区别,主要是 android:inputType="textPassword"
和 android:inputType="textWebPassword"
I hope it is clear now the differences and mainly between android:inputType="textPassword"
and android:inputType="textWebPassword"
这篇关于android:inputType=“textPassword"、“textVisiblePassword"、“textWebPassword"之间的区别和“数字密码"在安卓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:android:inputType=“textPassword"、“textVisiblePassw
基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01