I have 2 EditText views. I enter alphabetic text in the first one (whose Name & Tag is edtOSGBGridRef1) which is validated (by Sub edtOSGBGridRef1Valid i.e. Returns True) as OK. I now want to move to the other whose Name & Tag is edtOSGBGridRef2 (which requires numerics on its keyboard). However, the code shown below results in moving to another View - a button. I know that the Case of "edtOSGBGridRef1" is being executed due to a Log in the edtOSGBGridRef1 routine being displayed. I've removed the line "IME.HideKeyboard" with no success. I feel that it's something to do with the line "IME.ShowKeyboard(edtOSGBGridRef2)" being in this Sub. However, it doesn't seem correct to put it into the Sub edtOSGBGridRef1_FocusChanged where the test HasFocus = False is True.
B4X:
Sub IME_HandleAction As Boolean
Dim edt As EditText
edt = Sender
Log("IME_HandleAction:")
Log("EditText.Tag="&edt.Tag)
Select edt.Tag
Case "edtOSGBGridRef1"
If edtOSGBGridRef1Valid Then
IME.HideKeyboard
IME.ShowKeyboard(edtOSGBGridRef2)
Else
ToastMessageShow("Correct OSGB Grid Reference Map", True)
'Consume the event
'The keyboard will not be closed
Return True
End If
I've now abandoned the use of HandleAction as that gives problems with doing validation i.e. validation works OK when using Enter (i.e. Next) key but not if the next view is pressed without using Enter. I now know that the SetRequestFocus does not work for a button (btnOSGBGridRef) when I want to proceed to it from the last EditText view's (edtOSGBGridRef3) EnterPressed Sub as the value assigned to btnOSGBGridRef.SetRequestFocus is False: shown by a ToastMessage.
I've now abandoned the use of HandleAction as that gives problems with doing validation i.e. validation works OK when using Enter (i.e. Next) key but not if the next view is pressed without using Enter. I now know that the SetRequestFocus does not work for a button (btnOSGBGridRef) when I want to proceed to it from the last EditText view's (edtOSGBGridRef3) EnterPressed Sub as the value assigned to btnOSGBGridRef.SetRequestFocus is False: shown by a ToastMessage.