So I am using two different EditText for number input from the user. I am using “requestFocus” to switch between them.
When typing in the second EditText(minutes), I don’t want “requestFocus” to switch to hours directly when “length()==00”.
I want the switch to happen only when “length()==00” AND backspace is pressed. (As shown in image 4 below)
Here’s the solution I tried that don’t seem to work.
First I created a Boolean variable and set it to false:
I got an “setOnkeylisterner” that should change the value of “backSpace” to true when it is pressed AND when the minutes text field is empty
Then in EditText for the minutes I got an TextWatcher that “requestFocus” only when min.length = 0 AND “backspace = true”.
Also when then entering a number in the text field for hours, “backSpace” is set to false again:
Before i tried with this solution(backSpace and a java method "onKey" to track backspace), the EditText would change focus directly to hours. Like from image 2-4.
Now it only stays in the EditText for minutes no matter how many backspaces is being pressed so the problem might be with the tracking of the backspace key or something.
Any ideas on how I can implement the behavior I am looking for?
posted 1 month ago
After doing some research on this topic it seems like android can't detect backspace press from the onscreen keyboard :O