B4J Question Combox Not Refresh

Firpas

Active Member
Licensed User
Longtime User
I'm trying b4j combobox and i've found a Little problem.
Ithis is my code to fill the combobox.ítems list

B4X:
Sub DevicesFill
    Dim Img As Image
    Img.Initialize(File.DirAssets, "device.png")
 
    For i=0 To 5
        Dim Pnl As Pane
        Pnl.Initialize("ItemDev")
        Pnl.SetSize(CboDevices.Width, CboDevices.Height)
     
        Dim Icon As ImageView
        Icon.Initialize("ItemDev")
        Pnl.AddNode(Icon, 5, 5, Pnl.Height-10, Pnl.Height-10)
        Icon.SetImage(Img)
     
        Dim Lbl1 As Label
        Lbl1.Initialize("ItemDev")
        Pnl.AddNode(Lbl1, 80, 5, Pnl.Width - 80, 20)
        Lbl1.Text = "Device " & i
        Lbl1.TextColor = fx.Colors.From32Bit(0xFF000000)
     
        Dim Lbl2 As Label
        Lbl2.Initialize("ItemDev")
        Pnl.AddNode(Lbl2, 80, 30, Pnl.Width - 80, 20)
        Lbl2.Text = "936993322" & i
        Lbl2.TextColor = fx.Colors.From32Bit(0xFF7F7F7F)
     
        CboDevices.Items.Add(Pnl)
    Next
 
End Sub

When i click on checkbox firstime it look well, but selecting other ítem and clicking again, the ítems that has been selected aren´t visibles.

Is necesary to rfresh the ítems list??

How?

Attached you can find some screen shot.

Thanks in advance
 

Attachments

  • image1.png
    51.5 KB · Views: 326
  • image2.png
    49.3 KB · Views: 276

Daestrum

Well-Known Member
Licensed User
Longtime User
This was in the combobox api notes
A warning about inserting Nodes into the ComboBox items list
ComboBox allows for the items list to contain elements of any type, including Node instances. Putting nodes into the items list is strongly not recommended. This is because the default cell factory simply inserts Node items directly into the cell, including in the ComboBox 'button' area too. Because the scenegraph only allows for Nodes to be in one place at a time, this means that when an item is selected it becomes removed from the ComboBox list, and becomes visible in the button area. When selection changes the previously selected item returns to the list and the new selection is removed.
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
You can use my class called "custom combobox" which was initially designed to bypass this problem. See in my signature. You can modify it to support 2 lines of text.
 
Upvote 0
Top