简体   繁体   中英

How to paste autosuggested code from keyboard in different textinput field -Android

Currently, the issue is clicking on autosuggested text only filling the first textinput box, I want to fill all the six text inputs with the suggested code

Autosuggested Keyboard screen shot: 在此处输入图像描述

On clicking the autosuggested text, it is only filling first

在此处输入图像描述

Expected behaviour is to fill all the textinputs once user clicks on autosuggested code

This is a less explored use-case on StackOverflow, but, when you read Android docs for Auto-fill, in the OTP section, they have already provided generateSmsOtpHintForCharacterPosition which states and I quote:

When using multiple views where each view maps to a single digit of the OTP, you can use the generateSmsOptHintForCharacterPosition() method to generate per-character hints.

You can utilize the characterPosition parameter to auto-fill each EditText with the respective digit of the OTP auto-filled.

To do that, set

//Where Character Position (int) represents the digit position of the OTP for respective EditText, ranges from 1 to 8.
android:autofillHint="smsOTPCode{characterPosition}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM