自动填写不带国家代码的电话号码

问题描述 投票:0回答:1

我有一个包含电话号码的编辑文本。

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

android:autofillHints="phoneNumberDevice"
android android-edittext androidx phone-number autofill
1个回答
0
投票

使用AUTOFILL_HINT_PHONE_NATIONAL作为不带国家代码的电话号码

© www.soinside.com 2019 - 2024. All rights reserved.