Dim label1Index As Int=-1
Dim Label2Index As Int=-1
Dim i As Int=0
For Each v As B4XView In Activity.GetAllViewsRecursive
Log(i & ", " & v.Tag)
If v.Tag Is B4XPlusMinus Then
Dim bpm As B4XPlusMinus=v.Tag
LogColor("selected value=" & bpm.SelectedValue, Colors.Red)
LogColor("bpm.tag=" & bpm.tag, Colors.Red)
Else If v.Tag Is B4XFloatTextField Then
Dim fedt As B4XFloatTextField=v.Tag
LogColor("selected text=" & fedt.Text, Colors.Red)
LogColor("tag=" & fedt.tag, Colors.Red)
else If v Is Button Then
Dim btn As Button=v
LogColor("Button text=" & btn.Text, Colors.Red)
LogColor("button tag=" & btn.tag, Colors.Red)
Else if v Is EditText Then
Dim edt As EditText=v
LogColor("edittext: text=" & edt.Text & ", tag=" & edt.Tag, Colors.red)
Else if v Is Spinner Then
Dim spn As Spinner=v
LogColor(" spinner1 selected item=" & spn.SelectedItem & ", tag=" & spn.Tag, Colors.red)
Else if v Is Label Then
'label
Dim lbl As Label=v
If lbl =Null Or lbl.Tag=Null Then Continue
Select lbl.Tag
Case "Label1"
LogColor("lbl1: text=" & lbl.Text & ", tag=" & lbl.Tag, Colors.red)
label1Index=i
Case "Label2"
LogColor("lbl2: text=" & lbl.Text & ", tag=" & lbl.Tag, Colors.red)
Label2Index=i
End Select
End If
i = i +1
Next
If label1Index>=0 Then
Dim lbl As Label=Activity.GetView(label1Index)
LogColor("label1 text=" & lbl.Text, Colors.Red)
LogColor("label1 tag=" & lbl.tag, Colors.Red)
End If
If Label2Index>=0 Then
'Label2 is the very last view added
lbl=Activity.GetView(Label2Index) '<==this line causes error
LogColor("label2 text=" & lbl.Text, Colors.Red)
LogColor("label2 tag=" & lbl.tag, Colors.Red)
End If
End Sub