Android Question Focus problem

EddyW

Member
Licensed User
Longtime User
We created a activatie with a tabhost on it and each tab has its own panel with objects.
On one tab/panel we have 4 edittext and we want that the focus is on the 2th edittext of that tab/panel when the tab/panel is opened.

in code i placed in the tabChanged the following code
B4X:
    If TabHost1.CurrentTab = 6 Then
        EDT_WatermeterStand.RequestFocus
    End If

When i debug it see that the focus goes tot he 2th edittext (EDT_WatermeterStand)
and that there is no code running after it but the focus goes somehow back to the first edittext.

It looks like there is a event behind the tabChanged that places the focus back to the first edittext.
But we didnt write code for that, who knows in which event the focus is placed on the 1th edittext?
 

EddyW

Member
Licensed User
Longtime User
Thanx Erel,
Your idea worked
Only i had to use
B4X:
Sub SetFocus()
EDT_WatermeterStand.RequestFocus
End Sub

If TabHost1.CurrentTab = 6 Then
CallSubDelayed(Me, "SetFocus")
End If
With your solution i get a signature mismatch but your solution is better.
For now this works and when i have more time i figure out why it didnt work.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…