Android Question Nested CLV and Item Tags

moinamh

Member
I'm using this Code and trying to learn more about CLV.
in that Souce code for Nested CLV, We Can access Inner CLV items by Clicking them ( Log(Value) ).
But how can I get the inner item Parent Value/ID?
What I'm Asking is when I click inner items, Log shows me: The Item {3} was clicked from {2} Nested CLV. (Like the image below) :

firefox_e9gvxSKgTH_LI.jpg
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The nested CLV is not inside Title (2) item. It is inside the third item.

You can pass any data you like and add it as the nested item value:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    nested.Initialize(Activity)
    nested.base.LoadLayout("1")
    nested.CLV = CustomListView1
    For i = 1 To 10
        Dim Title As String = $"*** TITLE (${i}) ***"$
        CustomListView1.AddTextItem(Title, "")
        Dim p As B4XView = xui.CreatePanel("")
        p.SetLayoutAnimated(0, 0, 0, 100%x, 200dip)
        p.LoadLayout("Item")
        FillInnerList (Title)
        p.Tag = clvItem 'must set the Panel tag like this
        CustomListView1.Add(p, "")
    Next
End Sub

Sub FillInnerList (ParentTitle As String)
    For x = 1 To 10
        clvItem.AddTextItem($"Item #${x}"$, Array(ParentTitle, x))
    Next
End Sub

Sub CLVItem_ItemClick (Index As Int, Value As Object)
    Dim v() As Object = Value
    Dim Title As String = v(0)
    Dim Index As Int = v(1)
    Log($"${Title}: ${Index}"$)
End Sub
 
Upvote 0
Top