B4J Question TreeView at B4J

AndroidMadhu

Active Member
Licensed User
Hi,
I started learning B4J
I am working with Treeview at B4J.
I want to give custom name for every Item and child Item. Something Below screenshot.

1677735876809.png


Please advice how to get that

Thanks
 

AndroidMadhu

Active Member
Licensed User
I have done that as below :
B4X:
Private Sub Button1_Click
    'xui.MsgboxAsync("Hello world!", "B4X")
    Dim ti As TreeItem
    ti.Initialize("ti","Countries")
    Dim cti As TreeItem
    cti.Initialize("ti","Germany")
    ti.Children.Add(cti)
'    Dim ccti As TreeItem
'    ccti.Initialize("ti","Frankfruit")  ---- Here I am getting error. I want to add another Child Item Under Germany
'    ccti.Children.Add(ccti)
    TreeView1.Root.Children.Add(ti)
 
Upvote 0

AndroidMadhu

Active Member
Licensed User
I made this Mistake... fixed the same
B4X:
Dim ti As TreeItem
    ti.Initialize("ti","Countries")
    Dim cti As TreeItem
    cti.Initialize("ti","Germany")
    ti.Children.Add(cti)
    Dim ccti As TreeItem
    ccti.Initialize("cti","Frankfruit")
    cti.Children.Add(ccti)
    TreeView1.Root.Children.Add(ti)
 
Upvote 0

AndroidMadhu

Active Member
Licensed User
Actualluy the below event is not firing... I am not able to see any text at Label1 when selected any treeItems.

B4X:
Private Sub treeview_SelectedItemChanged (SelectedItem As TreeItem)
    Label1.Text=SelectedItem.Text
    
End Sub
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Actualluy the below event is not firing... I am not able to see any text at Label1 when selected any treeItems.

B4X:
Private Sub treeview_SelectedItemChanged (SelectedItem As TreeItem)
    Label1.Text=SelectedItem.Text
  
End Sub
That is because of a wrong event you named , I guess it is "treeview1".
 
Upvote 0
Top