Bug? TreeView error

Rzimski

Member
Dear all,

I think that in the treeView class is a bug.
Everytime I want to sort the children of my treeView throws a exception in the log screen.

B4X:
Private Sub sortTreeView()
tvArrangement.Root.Children.Sort(true)
End sub

The exception throws this message:
java.lang.ClassCastException: javafx.scene.control.TreeItem cannot be cast to java.lang.Comparable
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is not a bug. It is a limitation of TreeView.

The Sort method appears as Children is a standard List. However the items cannot be automatically compared.

You can sort the TreeView items by:
- Declare a custom type with Text As String and TI As TreeItem.
- Create a new list based on the TreeView items.
- Call List.SortType to sort the elements.
- Now add the items to the TreeView.
 
Top