Android Question FocusChanged Fires Unexpectedly

Ronald Berardinis

Member
Licensed User
I have a warehouse application where the prompts flow in a certain order.
Prompts work fine up to the point of saving a transaction.
At that point the application jumps to a EditText box _FocusChanged.
The application works fine when using 4in_Phone_Platform_24_Default_Platform from AVDManager.
FocusChanged does not fire.
But when using 4in_Phone_Platform_28_Defualt an unexpected text box focusChanged fires ??
the behavior is strange.
there is no RequestFocus to the errant textbox that is called.

 

Ronald Berardinis

Member
Licensed User
when the focuschanged is raised, the process clears the screen.
the application is prompt oriented.
the program builds the screen as someone answers the prompt correctly.
When the app starts, there is only one field on the screen. Basically a blank page.
If the prompt is answered correctly, move to the next prompt.
so the screen fills up with the required information and then when all questions are answered correctly, save prompt appears.
however, the save prompt does not appear.
The application jumps to another prompt previously answered and clears the screen from that prompt down.
then has to start again.
The app is now in a loop.
this does not behave when using the 24 default.
I have got around by putting the following in the focuschanged.
notice the dSaveActive.
I had to add to get the behavior I needed.

Sub txtBin_FocusChanged (HasFocus As Boolean)
If HasFocus And dSaveActive = False Then
ShowNextPrompt("BN",sNo)
End If
End Sub

but cannot explain why happening?
is this a bug?

also, is there a way to catch the "hasfocus" when click into the edittext box?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The focus is managed by the OS so it is likely not a bug in B4A. Many things can cause the focus to change, your app should expect it.

also, is there a way to catch the "hasfocus" when click into the edittext box?
You can handle the Click event (it is not listed but it will work).

The only thing that you should do when the focus is lost is validate the input and change the border color or something similar that will let the user know that the input is invalid. Let the user choose which view should be focused.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…