I have a sub which creates a GUI:
Each Edittext can be changed. When finished, I need to get the new values of each edittext to save a settings file. This is what I have tried:
Which gives me this in the log (Rapid debugger and emulator):
The problem is the NULL and the edittext which is changed, deletes the text. I cannot see my mistake!
B4X:
Sub Build_GUI2
'Prepare gradient
cols1(0) = Colors.ARGB(255,167,221,241)
cols1(1) = Colors.White
gd1.Initialize( "BOTTOM_TOP",cols1)
gd2.Initialize( "TOP_BOTTOM",cols1)
gd1.CornerRadius=0
gd2.CornerRadius=0
Activity.Background=gd2
Dim Labellist As List
Labellist.Initialize
Labellist.Add("Auto:")
Labellist.Add("Autocolor:")
Labellist.Add("Kennzeichen:")
Labellist.Add("Mitgliedsnummer:")
Labellist.Add("Name:")
Labellist.Add("Handynummer:")
Labellist.Add("VW Passat")
Labellist.Add("Hell Blau")
Labellist.Add("QB 145BG")
Labellist.Add("123456789")
Labellist.Add("John Doe")
Labellist.Add("06215589589")
For i=0 To 5
Dim lbl As Label
Dim edttxt As EditText
edttxt.Initialize("edttxt_Edit") 'All edittexts use the same sub, tag determines value
lbl.Initialize("")
'Add label
Activity.AddView(lbl, 15dip, i*100dip+10dip, Activity.Width/2, 40dip)
lbl.Background=gd1
lbl.Text=Labellist.Get(i)
lbl.TextColor=Colors.Black
'Add Edittext
Activity.AddView(edttxt, 25dip, i*100dip+50dip, Activity.Width/2, 40dip)
edttxt.Background=gd1
edttxt.Tag=Labellist.Get(i)
If SetDummyValues Then
edttxt.Text=Labellist.Get(i+6)
End If
Next
'Buttons
Dim bmd As BitmapDrawable
bmd.Initialize(LoadBitmap(File.DirAssets, "close.png"))
btnBack.Initialize("btnBack")
btnBack.Background = bmd
Activity.AddView(btnBack, 100%x-50dip, 100%y-50dip, 48dip,48dip)
End Sub
Each Edittext can be changed. When finished, I need to get the new values of each edittext to save a settings file. This is what I have tried:
B4X:
Sub edttxt_Edit_EnterPressed
For Each edttxt_Edit As EditText In Activity.GetAllViewsRecursive
Log(edttxt_Edit.Tag)
Log(edttxt_Edit.Text)
Next
End Sub
Which gives me this in the log (Rapid debugger and emulator):
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (settings) Create, isFirst = true **
** Activity (settings) Resume **
null
Auto:
Auto:
VW Passat
null
Autocolor:
Autocolor:
Hell Blau
null
Kennzeichen:
Kennzeichen:
QB 145BG
null
Mitgliedsnummer:
Mitgliedsnummer:
123456789
null
Name:
Name:
John Doe
null
Handynummer:
Handynummer:
06215589589
null
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (settings) Create, isFirst = true **
** Activity (settings) Resume **
null
Auto:
Auto:
VW Passat
null
Autocolor:
Autocolor:
Hell Blau
null
Kennzeichen:
Kennzeichen:
QB 145BG
null
Mitgliedsnummer:
Mitgliedsnummer:
123456789
null
Name:
Name:
John Doe
null
Handynummer:
Handynummer:
06215589589
null
The problem is the NULL and the edittext which is changed, deletes the text. I cannot see my mistake!