toby Well-Known Member Licensed User Longtime User Jul 17, 2022 #1 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. TIA i Attachments horizontalClvs.zip horizontalClvs.zip 26.5 KB · Views: 441
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. TIA i
MicroDrie Well-Known Member Licensed User Longtime User Jul 17, 2022 #2 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. Upvote 0
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.
toby Well-Known Member Licensed User Longtime User Jul 17, 2022 #3 MicroDrie said: 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. Click to expand... Could you show me how by modifying the attached project? Upvote 0
MicroDrie said: 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. Click to expand... Could you show me how by modifying the attached project?
toby Well-Known Member Licensed User Longtime User Jul 17, 2022 #4 MicroDrie said: 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. Click to expand... 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. Upvote 0
MicroDrie said: 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. Click to expand... 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.
josejad Expert Licensed User Longtime User Jul 17, 2022 #5 toby said: would like to know how to duplicate desinger views in code Click to expand... Do you mean something like Erel does in the XCustomListView example? 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 ,,,,, Upvote 0
toby said: would like to know how to duplicate desinger views in code Click to expand... Do you mean something like Erel does in the XCustomListView example? 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 ,,,,,
toby Well-Known Member Licensed User Longtime User Jul 17, 2022 #6 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. Upvote 0
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.
H Heuristx Active Member Licensed User Longtime User Jul 18, 2022 #7 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: [CODE lang="b4x" title="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[/CODE] Upvote 0
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: [CODE lang="b4x" title="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[/CODE]