Android Question CLVExpandable Members

Sergey_New

Well-Known Member
Licensed User
Longtime User
How to access buttons bt1, bt2, which are in the body of a list item, on event:
B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
'    bt1.Text="1"
'    bt2.Text="2"
End Sub
 

mangojack

Expert
Licensed User
Longtime User
B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)

    Sleep(400)  ' stops crash / error
    'Items Panel ...
    Dim pnlItems As B4XView = clv1.GetPanel(Index).GetView(1)   'pnlExpanded is Second Item /panel on Item layout
    pnlItems.GetView(0).Text = "ABC"      '1st button
    pnlItems.GetView(1).Text = "123"      '2nd button

PS: Refer to Designer / Tree View for Panel / Child view index order



 
Last edited:
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
mangojack, thanks!
Tell me how to contact B4XComboBox?
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Okay, but B4XComboBox is in the same place as bt1 and bt2. :)
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Did you read the above link posted by @Erel ?

To solve this problem the following convention is used in all XUI Views and is recommended for all new custom views:
The class instance is set to the base panel Tag property.
This allows developers to get the class instance using the base panel Tag property:


I have not used /tested but try ...
B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
    Sleep(400)  ' stops crash / error
    'Items Panel ...
    Dim pnlItems As B4XView = clv1.GetPanel(Index).GetView(1)   'pnlExpanded is Second Item /panel on Item layout
    Dim combo1 = pnlItems.GetView(0).Tag  '1st B4XComboBox
    Dim combo2 = pnlItems.GetView(1).Tag  '2nd Combo
    
    combo1.SetItems(Array(())  'clear the combobox
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I have corrected the above code ...
B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
    Sleep(400)  ' stops crash / error
    'Items Panel ...
    Dim pnlItems As B4XView = clv1.GetPanel(Index).GetView(1)   'pnlExpanded is Second Item /panel on Item layout
    Dim combo1 As B4XCombobox = pnlItems.GetView(0).Tag  '1st B4XComboBox
    Dim combo2 As B4XComboBox = pnlItems.GetView(1).Tag  '2nd Combo
   
    combo1.SetItems(Array(())  'clear the combobox[/code
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I read it, but did not understand how to install several B4XComboBox items in pnlItems.Tag.

You do not have to ....

You said you have 2 B4XComboBoxes in place of the Buttons (in the example) ??

Just Add B4XComboBoxes to the "Items" Layout ...

Populate them in the CreateItem Sub ...
B4X:
Sub CreateItem(clr As Int, Title As String, ExpandedHeight As Int) As B4XView
    '.................. code
    B4XComboBox1.SetItems(Array(..........)
    '................. more code


you can access / edit them later (In a clv1_ItemClick or elsewhere ) if you need to later with the above code. (post #9)
 
Last edited:
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
mangojack, thanks!
I correctly understood that if the element is part of the B4XView, then it needs to be accessed:
B4X:
Dim cmb1 As B4XComboBox = pnlItems.GetView(0).Tag
if not, then:
B4X:
Dim et1 As EditText = pnlItems.GetView(1)
Is the numbering of elements end-to-end regardless of the type?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Is the numbering of elements end-to-end regardless of the type?

If I understand correctly .. child Views , Yes. (Everything is relevant to the Parent) ie:

Referring to the Designer Tree View ...
Container / Panel 1 = 0 (child views, 0 - n)
Container / Panel 2 = 1 (child views, 0 - n)

The Visual order can be different to the Tree Index order (you can drag views / swap tree order to suit)
I occasionally change tree order to neaten ? / align code when accessing / populating views with DB data

PS: I believe under certain circumstances, calls to .BringToFront, .SendToBack , could alter view indexes
 
Last edited:
Upvote 0
Top