I have a ScrollView with several B4XComboBox objects on it. I'd like to loop through them and get the selected text. I'm trying:
B4X:
Dim obj As Object = ScrollView1.Panel.GetView((i*5)+4)
Dim cmb As B4XComboBox = obj
Dim X,Y As String
X = cmb.SelectedItem
Y = cmb.cmbBox.SelectedItem
Both cmb.SelectedItem and cmb.cmbBox.SelectedItem cause errors. I'm think that the first two lines of the code (obj and cmb) are incorrect somehow. Any ideas?
fyi - here's how the comboboxes are initially created:
B4X:
Dim cmb As B4XComboBox
cmb.Initialize("cmb", Null)
cmb.Tag = "cmb_" & i
cmb.cmbBox.Initialize("cmbBox")
cmb.cmbBox.Tag = "cmbBox_" & i
cmb.cmbBox.TextSize = 12
cmb.cmbBox.Add("None")
cmb.cmbBox.Add("Test")
cmb.SelectedIndex = 0
ScrollView1.Panel.AddView(cmb.cmbBox, 65%x, ItemHeight * i, ScrollView1.Width, ItemHeight - 1dip)
Custom views are designed to be added with the designer. It is however very simple to create a layout file with the custom view and load it multiple times. Tip: remove the call to AutoScaleAll from the designer script. Complete example: Sub Globals Private B4XSwitch1 As B4XSwitch End...
This is a common question and for a good reason. Custom views classes are not views by themselves. The views tree only holds views. This means that this code cannot work: Dim B4XFloatTextField1 As B4XFloatTextField = CLV.GetPanel(x).GetView(y) The actual view that is added to the views tree...
Thanks for replying. That works for getting the Tag. Both lines 4 & 5 of the sample code in original posting still fail, however, for getting the SelectedItem. Or are you recommending that I update the Tag(s) on the SelectedIndexChanged event?
Custom views are designed to be added with the designer. It is however very simple to create a layout file with the custom view and load it multiple times. Tip: remove the call to AutoScaleAll from the designer script. Complete example: Sub Globals Private B4XSwitch1 As B4XSwitch End...
This is a common question and for a good reason. Custom views classes are not views by themselves. The views tree only holds views. This means that this code cannot work: Dim B4XFloatTextField1 As B4XFloatTextField = CLV.GetPanel(x).GetView(y) The actual view that is added to the views tree...
Custom views are designed to be added with the designer. It is however very simple to create a layout file with the custom view and load it multiple times. Tip: remove the call to AutoScaleAll from the designer script. Complete example: Sub Globals Private B4XSwitch1 As B4XSwitch End...
This is a common question and for a good reason. Custom views classes are not views by themselves. The views tree only holds views. This means that this code cannot work: Dim B4XFloatTextField1 As B4XFloatTextField = CLV.GetPanel(x).GetView(y) The actual view that is added to the views tree...
Well, that was it. Excellent example, thanks. I think I missed those articles because I stopped using b4x for several years (and just started updating an old app this week).