B4A Library [B4X] [XUI] SD_TreeList

Download a Library from Here

SD_TreeList

Author:
Star-Dust
Version: 0.19
  • B4XTree
    • Events:
      • Click (IDLeaf As String, LeafName As String)
      • ClickBranch (ID As String, Expanded As Boolean)
      • LongRightClick (IDLeaf As String, LeafName As String)
    • Fields:
      • BadgeBackgroundColor As Int
      • BadgeDept As Int
      • BadgeTextColor As Int
      • BadgeTextSize As Int
    • Functions:
      • Add (Name As String, IDBranch As String, FontAwesoneSymbol As String, Color As Int, ListLeaf As String()) As String
        Add Branch with Symbol(FontAwesone) and Leaf (list)
      • Add2 (Name As String, IDBranch As String, Symbol As String, FontSymbol As B4XFont, Color As Int, ListLeaf As String()) As String
        Add Branch with Symbol(FontAwesone) and Leaf (list)
      • AddBranch (Name As String, IDBranch As String, IDParent As String, FontAwesoneSymbol As String, Color As Int) As String
        Add Branch
      • AddBranch2 (Name As String, IDBranch As String, IDParent As String, Symbol As String, FontSymbol As B4XFont, Color As Int) As String
        Add Branch with Symbol
      • AddBranchDoubleSymbol (Name As String, IDBranch As String, IDParent As String, OpenSymbol As String, CloseSymbol As String, FontSymbol As B4XFont, Color As Int) As String
        Add Branch with double symbol
      • AddDoubleSymbol (Name As String, IDBranch As String, OpenSymbol As String, CloseSymbol As String, FontSymbol As B4XFont, Color As Int, ListLeaf As String()) As String
        Add Branch with double Symbol and Leaf (list)
      • AddLeaf (Name As String, Info As String, IDBLeaf As String, IDParent As String) As String
        Add Leaf to branch
      • AddLeafOnTop (Name As String, Info As String, IDLeaf As String, IDBranch As String) As String
        Add Leaf on top to Branch
      • Class_Globals As String
      • Clear As String
      • CollapsesAllBranch As String
      • CollapsesBranch (IDBranch As String) As String
      • CollapsesBranchAndSOn (IDBranch As String) As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • ExpandAllBranch As String
      • ExpandBranch (IDBranch As String) As String
      • ExpandBranchAndSon (IDBranch As String) As String
      • GetBranchName (IDBranch As String) As String
      • GetBranchOfLeaf (IDLeaf As String) As String
      • GetLeafInfo (IDLeaf As String) As String
      • GetLeafName (IDLeaf As String) As String
      • Initialize (Callback As Object, EventName As String) As String
      • Invalidate
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • ListOfIDBraches (IDBranche As String) As List
        Returns a list of strings
        This list contains the IDs of the sub-branches attached To a branch
      • ListOfIDLeafs (IDBranche As String) As List
        Returns a list of strings
        This list contains the IDs of the leaves attached To a branch
      • MoveLeaf (IDLeaf As String, NewIDBranch As String) As String
      • RemoveBranch (IDBranch As String) As String
      • RemoveLeaf (IDLeaf As String) As String
      • SetBranch (IDBranch As String, NewName As String) As String
      • SetLayout (Left As Int, Top As Int, Widh As Int, Height As Int) As String
      • SetLeaf (IDLeaf As String, NewName As String, NewInfo As String) As String
      • SetLeafBadge (IDLeaf As String, BadgeActive As Boolean, BadgeText As String) As String
      • Sort (Ascending As Boolean) As String
      • TreeToJson As String
    • Properties:
      • Base As B4XView [read only]
      • BranchTextColor As Int
      • Height As Int
      • ItemHeight As Int
        Min = 40dip, Max= 100dip
      • LeafTextColor As Int
      • Left As Int
      • OnlyCornerColor As Boolean
      • OpenOnlyOneBranch As Boolean
      • TextSize As Int
      • TimeAnimation As Int
      • Top As Int
      • Width As Int


Preview.gif


Badge on leaf
1614958994789.png
 
Last edited:

iz0ndg

Active Member
Licensed User
Longtime User
Error to launch sample:


B4X:
Logger connesso a: 1234567890123456
--------- beginning of crash
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
b4xtree_vv3 (java line: 286)
java.lang.RuntimeException: Font asset not found b4x_fontawesome.otf
   at android.graphics.Typeface.createFromAsset(Typeface.java:190)
   at anywheresoftware.b4a.objects.TextViewWrapper.getTypeface(TextViewWrapper.java:155)
   at anywheresoftware.b4a.keywords.constants.TypefaceWrapper.getFONTAWESOME(TypefaceWrapper.java:52)
   at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.CreateFontAwesome(B4XViewWrapper.java:699)
   at b4a.example.b4xtree._vv3(b4xtree.java:286)
   at b4a.example.b4xtree._vv7(b4xtree.java:386)
   at b4a.example.b4xtree._v6(b4xtree.java:138)
   at b4a.example.main._activity_create(main.java:345)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
   at b4a.example.main.afterFirstLayout(main.java:104)
   at b4a.example.main.access$000(main.java:17)
   at b4a.example.main$WaitForLayout.run(main.java:82)
   at android.os.Handler.handleCallback(Handler.java:815)
   at android.os.Handler.dispatchMessage(Handler.java:104)
   at android.os.Looper.loop(Looper.java:207)
   at android.app.ActivityThread.main(ActivityThread.java:5845)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)
 

Star-Dust

Expert
Licensed User
Longtime User
I updated the example to load the Awesome Font
B4X:
Activity.LoadLayout("main")

    B4XTree1.AddBranch("Branch 1","1",Chr(0xF0F9),Colors.Gray)
    B4XTree1.AddLeaf("Leaf A","1")
    B4XTree1.AddLeaf("Leaf B","1")
    B4XTree1.Add("Branch 2","2",Chr(0xF0E9),0xFF566DFF,Array As String("Sub A","Sub B","Sub C"))
    B4XTree1.Add("Branch 3","3",Chr(0xF0F5),0xFF1B8921,Array As String("Leaf D","Leaf E","Leaf F"))
    For I=67 To 87
        B4XTree1.AddLeaf("Leaf " & Chr(I),"1")
    Next
    
    'Instruction useful only for the compiler to load FontAwesone
    Dim BF As B4XFont= xui.CreateFontAwesome(14) 'ignore
 

Unobtainius

Active Member
Licensed User
Longtime User
Thanks man, dying to try it, I love your stuff
 

Unobtainius

Active Member
Licensed User
Longtime User
Finally had time to have a look.
As always, it's a work of art.
I guess the next logical step is to allow branches to have other branches as well as leaves
 

Star-Dust

Expert
Licensed User
Longtime User
it may be that I will be able to add branches in the branches.

Surely in the next update over a better animation you will be able to open more branches at the same time
 

Unobtainius

Active Member
Licensed User
Longtime User
it would be nice to have it as a property, open single, or open multiple. That way you would have the option to restrict the user to only open one branch at a time if it suits the situation better. What ever you decide to do, I know it will be great.
 

Star-Dust

Expert
Licensed User
Longtime User
The idea is that of having it as property.
It's a simple thing to do but I'm off site I don't know if I can do it today
 

Unobtainius

Active Member
Licensed User
Longtime User
There's no hurry for me. I was just making suggestions :)
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.02
Add Animation
Add filed: OpenOnlyOneBranch As Boolean
 
Last edited:

Unobtainius

Active Member
Licensed User
Longtime User
Works well, nice job ;)
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.03 improved animation
 

Unobtainius

Active Member
Licensed User
Longtime User
subtle, but nice.
 

Unobtainius

Active Member
Licensed User
Longtime User
If there was some way to load a layout into a branch it may be possible to load another treeview in there and build a hierarchical tree?
I have no idea of the complexity of doing so, or if it is even possible?
 

Star-Dust

Expert
Licensed User
Longtime User
If there was some way to load a layout into a branch it may be possible to load another treeview in there and build a hierarchical tree?
I have no idea of the complexity of doing so, or if it is even possible?
No need to complicate with another Layout.
It is possible to do it recursively, it is not even complicated .... but the readability would be reduced.

Let's see there study a little
 

Unobtainius

Active Member
Licensed User
Longtime User
so you are saying something along these lines wouldn't be particularly complicated?
tree.png

Ok. It's beyond me. But I will get there eventually
 

Star-Dust

Expert
Licensed User
Longtime User
so you are saying something along these lines wouldn't be particularly complicated?

Ok. It's beyond me. But I will get there eventually
It is not complicated, indeed the original project on which I was inspired is the Z-Tree-List (which at the moment I can no longer find myself in the forum) which very simply managed branches inside the branches. There is not much to change except one or two lines of code. But at the moment I am not convinced that visually it is effective.

@Star-Dust Is that possible to put panel inside a Leaf, instead of just strings?

I mean to make more flexible this lines.
Already the xCustomListView has the possibility to insert Layout in each Item and it can also Collapse the branches (see here). I don't think it is necessary to create something like this since it already exists and is done very well by @Erel.
 
Top