Nis*_*ita 5 android autofill phone-number android-edittext androidx
我有一个包含电话号码的编辑文本。
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_mobile_number"
style="@style/EditTextBoxNumeric"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:maxLength="@integer/max_phone_number_length"
android:autofillHints="phoneNumberDevice"
/>
Run Code Online (Sandbox Code Playgroud)
Android 尝试使用电话号码自动填充此编辑文本,但同时会同时填充国家/地区代码。由于我对该编辑文本可以容纳的字符数有上限,因此该数字的最后三位数字被删除。
例如,编辑文本显示数字的自动填充选项 (+91 77777 77890),单击该选项后,编辑文本将仅填充 (+91 77777 777)。我需要的只是(77777 77890)而不是国家/地区代码(+91)。
我努力了
binding.etMobileNumber.setAutofillHints(HintConstants.AUTOFILL_HINT_PHONE_NUMBER_DEVICE)
binding.etMobileNumber.setAutofillHints(HintConstants.AUTOFILL_HINT_PHONE_NATIONAL)
Run Code Online (Sandbox Code Playgroud)
和
android:autofillHints="phoneNumberDevice"
android:autofillHints="phoneNational"
Run Code Online (Sandbox Code Playgroud)
用于AUTOFILL_HINT_PHONE_NATIONAL
没有国家/地区代码的电话号码
binding.etMobileNumber.setAutofillHints(
HintConstants.binding.etMobileNumber.setAutofillHints(HintConstants.AUTOFILL_HINT_PHONE_NATIONAL))
Run Code Online (Sandbox Code Playgroud)
在 XML 中phoneNational
这是文档https://developer.android.com/reference/androidx/autofill/HintConstants#AUTOFILL_HINT_PHONE_NATIONAL
归档时间: |
|
查看次数: |
3555 次 |
最近记录: |