Android Question Q about catching Focus of code generated edittexts in B4X

padvou

Active Member
Licensed User
Longtime User
Hello,
my code creates several B4Xviews which are EditTexts and I need to catch the event of a user clicking on any of them to type something.
Here's the relevant snippet:
B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore

    Private txtInput As B4XView
End Sub

Sub Some_subname
For i = 0 To MyList.Size - 1
        Dim map As Map
        map.Initialize
        map = ItemsList.Get(i)
        Dim val1 As Double = map.Get("VAL1")
        Dim val2 As Double = map.Get("VAL2")
        Dim val3 As Int = map.Get("VAL3")  
                #if B4A
        Dim nativeEditText As EditText
        nativeEditText.Initialize("txtInput")
        txtInput = nativeEditText
                #Else If B4J
                    Dim nativeTextField As TextField
                    nativeTextField.Initialize("txtInput")
                    txtInput = nativeTextField
                #Else If B4i
                    txtInput = xui.CreateTextField("txtInput") ' For B4i
                #End If
        txtInput.SetTextAlignment("BOTTOM", "CENTER")
        txtInput.TextColor = xui.Color_Black
        txtInput.TextSize=13
        txtInput.Tag = Array As Double(val1, val2, val3)
        TableLayout.AddView(txtInput, i * boxWidth, i * boxHeight, boxWidth, boxHeight)      
    Next

End Sub
 
Top