I have some code that iterates through all the loaded views and pulls the values from the views that users can enter data into (such as a spinner, edittext, etc...). The problem comes in with adding custom views or XUI views.
Consider the following function:
Everything works great for traditional views, but the problem comes in when you get to the condition for B4XComboBox and AnotherDatePicker. The "Is" operator does not identify the view as being the type that is shown. Is the only answer to identify these custom views by tags?
Consider the following function:
B4X:
Sub get_field_data As Map
LogColor("get_field_data",Colors.Yellow)
Dim m As Map
m.Initialize
For Each v As View In pnldata.GetAllViewsRecursive
Dim t As String
t=v.Tag
If t<>"" And t<>"null" And t<>"XUI" Then
Log("tag="&t)
LogColor(GetType(v),Colors.Red)
If v Is EditText Or v Is AutoCompleteEditText Then
Dim v2 As EditText
v2.Initialize("")
v2=v
Try
m.Put(t.SubString2(0,t.IndexOf(" ")),v2.Text)
Catch
End Try
End If
If v Is Spinner Then
Dim sp As Spinner
sp.Initialize("")
sp.Tag=t
sp=v
Try
m.Put(t.SubString2(0,t.IndexOf(" ")),sp.SelectedIndex)
Catch
End Try
End If
If v Is Button Then
Dim b As Button
b.Initialize("")
b=v
Try
m.Put(t.SubString2(0,t.IndexOf(" ")),b.Text)
Catch
End Try
End If
If v Is B4XComboBox Then
LogColor("Found B4xcombobox!",Colors.green)
Dim cb As B4XComboBox
cb=v
Try
m.Put(t.SubString2(0,t.IndexOf(" ")),cb.GetItem(cb.SelectedIndex))
Catch
End Try
End If
If v Is AnotherDatePicker Then
LogColor("Found AnotherDatePicker!",Colors.green)
Dim adp As AnotherDatePicker
adp=v
Try
m.Put(t.SubString2(0,t.IndexOf(" ")),adp.Date)
Catch
End Try
End If
End If
Next
Return m
End Sub
Everything works great for traditional views, but the problem comes in when you get to the condition for B4XComboBox and AnotherDatePicker. The "Is" operator does not identify the view as being the type that is shown. Is the only answer to identify these custom views by tags?