How to determine which edittext had focus?

U

unba1300

Guest
Hello,

I am using code like the following to add to a list what text is in each of ten edittexts when the activity gets paused:

B4X:
Dim et As EditText
For i = 9 To 0 Step -1 
  et = sv1.Panel.GetView(i)
  lst1.Add(et.text)
Next

But could someone please tell me how to determine in this loop which edittext the user is using at the time (so that I can set the cursor back there during Resume). Thanks.
 

Ricky D

Well-Known Member
Licensed User
Longtime User
Maybe try this

On each textview why don't you capture the viewname

B4X:
Sub Process_Globals
Dim ViewName as string
End Sub
.
.
.
Sub aView_FocusChanged (HasFocus As Boolean)
    If HasFocus=True Then ViewName = "aView"
End Sub


where aView is the textview. When the activity gets restarted look for which one (if any) had focus

B4X:
Sub Activity_Resume
    Select ViewName
        Case "aView"
            aView.RequestFocus
.
.
other views
    End Select

There may be other ways to do it but I can only see this one. I can be a little shortsighted at times lol.
 
Upvote 0
Top