I have a set of four EditText views that are used to input a 4 digit code. Each one of these is set to a maxLength of 1, because they hold a single of those digit.
Now I want to allow my users to copy the four digit code and paste it directly into the 4 fields.
I have tried detecting the paste event using:
@Override
public boolean onTextContextMenuItem(int id) {
boolean consumed = super.onTextContextMenuItem(id);
switch (id){
case android.R.id.cut:
onTextCut();
break;
case android.R.id.paste:
onTextPaste();
break;
case android.R.id.copy:
onTextCopy();
}
return consumed;
}
like in this question, but I have no way of returning the pasted text in the callback.
I also tried with:
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { }
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
But out of the text being pasted I only get 1 char, I guess because the maxLength is set to 1.
How can I achieve the desired behavior?