[英]Android Autofill Phone Number not appearing, only showing 'Passwords'
我正在嘗試在 EditText 字段中使用 Android 的自動填充功能,以在鍵盤頂部向用戶提供使用與其設備/帳戶關聯的電話號碼的建議,如下圖所示。
我嘗試將android:autofillHints="phone"
和android:autofillHints="phoneNumber"
添加到 xml 文件中以進行布局。 這兩個選項都導致出現此“密碼”按鈕的左側屏幕截圖。 (我還在實際設備而不是模擬器上測試了這段代碼)
要查看我是否沒有正確使用自動填充或者這是設備/帳戶問題,我嘗試將代碼更改為android:autofillHints="emailAddress"
。 這導致正確的屏幕截圖顯示該帳戶的 email 地址(為保護隱私而編輯)。 這使我相信我的帳戶中可能沒有保存電話號碼,或者這就是為什么它默認為“密碼”的原因。
我的問題是:
任何幫助將不勝感激。
這是編輯文本的 xml 代碼:
<EditText
android:id="@+id/appt_type_phone_number_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="phone"
android:importantForAutofill="yes"
android:background="@android:color/transparent"
android:ems="10"
android:hint="@string/enter_phone_number"
android:inputType="phone"
android:maxLength="16"
android:textSize="14sp"
android:padding="16dp"
tools:targetApi="O"
/>
這取決於您的自動填充服務為您的應用提供的內容。
& 3. 您可以通過編程方式設置 autofillHints。
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) binding.appt_type_phone_number_text.setAutofillHints(View.AUTOFILL_HINT_PHONE) }
參考: 針對自動填充優化您的應用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.