Android Question How to do it in CLVExpandable

Sergey_New

Well-Known Member
Licensed User
Longtime User
B4X:
Private EditText1 As EditText
Private cmb As B4XComboBox
These items are on the 2nd panel
B4X:
Sub cmb_SelectedIndexChanged (Index As Int)
'    EditText1.Text=cmb.SelectedItem ???
End Sub
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
LucaMs, this is what I did. But the text does not change in the current EditText1, but in EditText1 in the last row of the list.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Normally you would use the following to get the index of the Item / row you are interacting with ... but that is not the case with custom views.
B4X:
Sub cmb_SelectedIndexChanged (Index As Int)
Dim MyIndex As Int = CLVExpand1.GetItemFromView(Sender)

I tried to follow this ... but I could not get it to work with CLV Expandable class'

I managed to get this to work OK ...
Set the index to the B4XCombobox.Tag when loading items ...

B4X:
For i = 1 To 20  '@From the Example ...
        Dim p As B4XView = CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), "Item #" & i,    i    , Rnd(100dip, 300dip) + 60dip)
        clv1.Add(p, expandable.CreateValue(p, "some value"))
    Next
End Sub

Sub CreateItem(clr As Int, Title As String, Index As Int, ExpandedHeight As Int) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, clv1.AsView.Width, ExpandedHeight)
    p.LoadLayout("Item")
    B4XComboBox1.Tag = Index -1    '*above loop = starts at 1.
    '........................

Sub B4XComboBox1_SelectedIndexChanged (Index As Int)
    Dim Combo As B4XComboBox = Sender
    Dim Index As Int = Combo.Tag
    Dim pnl As B4XView = clv1.GetPanel(Index)
    Dim pnlItem As B4XView = pnl.GetView(1) 'Items Panel
    pnlItem.GetView(1).Text= Combo.GetItem(Index)  'EditText  *check Designer View Tree Index
End Sub

maybe @Erel will suggest a solution
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
LucaMs, this is what I did. But the text does not change in the current EditText1, but in EditText1 in the last row of the list.

@LucaMs ... He has an EditText in the Item Layout . It is this EditText he wants to populate... not one on the "main" layout.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
LucaMs, In this example, EditText1 is not in the same panel as B4XComboBox1.
I have both elements belonging to the same panel.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
But it's still interesting to get the panel index without using Combo.Tag

As I stated in post #4 ... (with Changes to make it clearer)
Normally you could use the following code to get the Index of the Item/Row you want to access ... but that is not the case with custom views.
B4X:
Sub MyNormalSpinnerView_SelectedIndexChanged (Index As Int)
Dim MyIndex As Int = CLVExpand1.GetItemFromView(Sender)

With Custom Views you have to use the .Tag method ... (See link post #4)
 
Upvote 0
Top