B4J Question How dynamically Assign and MAP childitems at Treeview

AndroidMadhu

Active Member
Licensed User
Hello ,
I have created treeview with name of countries. as below ...

B4X:
ub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private TreeView1 As TreeView
    Private Button1 As Button
    Private Button2 As Button
    Private cp,conp As TreeItem
    Private conindia, conus,congermany,condutch,consweden As TreeItem
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
    
    cp.Initialize("cp","Country")
    conp.Initialize("conp","Continants")
    'Adding country list
    
    conindia.Initialize("cp","India")
    conus.Initialize("cp","US")
    congermany.Initialize("cp","Germany")
    condutch.Initialize("cp","NetherLand")
    consweden.Initialize("cp","Sweden")
    'Adding countries to Treeview
    cp.Children.Add(conindia)
    cp.Children.Add(conus)
    cp.Children.Add(congermany)
    cp.Children.Add(condutch)
    cp.Children.Add(consweden)
    
    'Adding to Root List
    TreeView1.Root.Children.Add(cp)
    TreeView1.Root.Children.Add(conp)
    
End Sub

Now I want to MAP and assign the key value dynamically. [To assign and get Index value].
I am trying another way other than assigning INDEX to childItems

How Do I do that?

Thanks
 
Top