Hello,
I create an activity that contains an array of editText. I saw some examples to know wich editText get the focus but it doesn't work for me...
I create an activity with an array of 10 editText but the 2 sub EditTexts_EnterPressed and EditTexts_FocusChanged doesn't work.
if I click on an editBox, the function EditTexts_FocusChanged is not called.
What am i doing wrong?
Thank you for your help
I post the example :
I create an activity that contains an array of editText. I saw some examples to know wich editText get the focus but it doesn't work for me...
I create an activity with an array of 10 editText but the 2 sub EditTexts_EnterPressed and EditTexts_FocusChanged doesn't work.
if I click on an editBox, the function EditTexts_FocusChanged is not called.
What am i doing wrong?
Thank you for your help
I post the example :
B4X:
Sub Globals
Private mainPage As B4XMainPage
Private EditTexts(10) As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
mainPage = B4XPages.MainPage
Dim i As Int
Dim Row As Int
Row = 10%x
For i = 0 To 9
EditTexts(i).Initialize("EditTexts" & i)
EditTexts(i).tag = i
EditTexts(i).text = "Blalbla" & i
EditTexts(i).Gravity = Gravity.CENTER
Activity.AddView(EditTexts(i),20%x, Row, 20%x, 5%y)
Row = Row + 5%y
Next
mainPage.resizeViews(Activity)
End Sub
Sub EditTexts_EnterPressed
Dim Row As Int
Private edt As EditText
edt = Sender
Row = edt.Tag
End Sub
Sub EditTexts_FocusChanged(HasFocus As Boolean)
Dim Row As Int
Private edt As EditText
Dim Couleur As Int
edt = Sender
Row = edt.Tag
If Not (HasFocus) Then
If Row/2 = Round(Row/2) Then
Couleur = Colors.White
Else
Couleur = Colors.Cyan
End If
Else
Couleur = Colors.Blue
End If
EditTexts(Row).Color = Couleur
End Sub