本文介绍了android:inputType=“textPassword"、“textVisiblePassword"、“textWebPassword"之间的区别和“数字密码"在安卓?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
谁能解释一下两者的区别
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_PASSWORDi.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_PASSWORDand 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_PASSWORDsame 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_PASSWORDand 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 anEditTextnative control. An example of using this would be to disable AutoSuggestion from Android in a WebView by wrapping aWebViewand changingEditorInfoinput type to add the flagInputType.TYPE_TEXT_VARIATION_WEB_PASSWORDinside theonCreateInputConnectionmethod.
作为从链接中截取的最后一个示例:
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"之间的区别和“数字密码"在安卓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)