【发布时间】:2020-04-29 21:45:45
【问题描述】:
我有一个包含电话号码的编辑文本。
<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"
/>
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)
和
android:autofillHints="phoneNumberDevice"
android:autofillHints="phoneNational"
【问题讨论】:
标签: android android-edittext androidx phone-number autofill