I use customlistviews to show grouped data with horizontal orientation. Currently there ae 14 groups and I use a label and a CustomListView to show each group of data; the views at the bottom are difficult to work with because they're too small in size to be readable. I think there must be a better way since each group of views are identical except the data shown. How do I have one set of views (label and clv) in the Designer and duplicate them in code for other groups instead of having 14 sets? Test project attached.
You can try to simplify the code by placing an equivalent code in a sub and adding a unique tag in that sub. Then the tag can be used with a click to make the correct handling.
You can try to simplify the code by placing an equivalent code in a sub and adding a unique tag in that sub. Then the tag can be used with a click to make the correct handling.
You can try to simplify the code by placing an equivalent code in a sub and adding a unique tag in that sub. Then the tag can be used with a click to make the correct handling.
Thanks for reminding me! Now I use same event name for all CLVs and as a result code is simplified significantly. I still would like to know how to duplicate desinger views in code.
Sub CreateListItem(Text As Map, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.SetLayout(0, 0, Width, Height)
p.LoadLayout("your_item_layout") ‘<—— your layout with the label and your horizontal xclv
,,,,,
There are 14 identical customListiviews and I would like to define just one of them in the designer and duplicate it 13 times at runtime and place them one below another in a scrollview. Currently I define all of them in the designer, resulting in a long layout which is hard to read.
Design a layout with just your listview or a panel with stuff, you can duplicate complex layouts, too.
You can have an invisible panel in your layout(panLoad), set to a correct size and do this:
Duplicate your view in code:
Sub Class_Globals
...
Private lv As B4XView
...
End Sub
'and in a Sub somewhere:
For i = 1 To 13
panLoad.LoadLayout("MyListView")
panListViewsParent.AddView(lv, x, y, ListViewWidth, ListViewHeight)
'change x
'change y
Next