Good day!
How to get the data entered in the fields array EditText?
'The user enters data
B4X:
Sub EnterNumer
Dim EditText1 As EditText
For i = 1 To 5
EditText1.Initialize ("")
Numer(i)= EditText1.Text
Next
End Sub
'Read the entered data
Sub ReadNumer
Dim EditText1 As EditText
For i = 1 To 5
EditText1.Initialize ("")
EditText1.Text = Numer(i)
Next
End Sub
You should define an array of EditText views and use indexes from 0 to 4.
B4X:
' in Globals
Private EditTexts() As EditText
' in Activity_Create
EditTexts = Array As EditText(EditText0, EditText1, EditText2, EditText3, EditText4)
Sub EnterNumer
For i = 0 To 4
Numer(i)= EditTexts(i).Text
Next
End Sub
'Read the entered data
Sub ReadNumer
For 0 = 1 To 4
EditTexts(i).Text = Numer(i)
Next
End Sub
' in Globals
Private EditTexts(5) As EditText
'further as it was:
Sub EnterNumer
For i = 0 To 4
Numer(i)= EditTexts(i).Text
Next
End Sub
'Read the entered data
Sub ReadNumer
For 0 = 1 To 4
EditTexts(i) = Numer(i)
Next
End Sub
No, you need to define which EditText object belongs to each item in the array.
That's what EditTexts = Array As EditText(EditText0, EditText1, EditText2, EditText3, EditText4) does.
You cannot define an array of objects in the Designer.
I just saw that EditTexts(i) = Numer(i) should be EditTexts(i).Text = Numer(i), amended in post #2.
To check which EditText raised the event you should use the Sender object and the Tag property:
You could set the Tag property to 0 for EditText0, to 1 for EditText1 etc. to get the Index
B4X:
Sub EditTexts_EnterPressed
Private edt As EditText
Private Index As Int
edt = Sender
Index = edt.Tag
'and your code
End Sub