B4A Library [B4X] [XUI] SD_TreeList

Star-Dust

Expert
Licensed User
Version for Android, iOS, Desktop
Required FontAweson

SD_TreeList

Author:
Star-Dust
Version: 0.08
  • B4XTree
    • Events:
      • Click (IDLeaf As String, LeafName As String)
      • ClickBranch (ID As String, Expanded As Boolean)
      • LongRightClick (IDLeaf As String, LeafName As String)
    • Functions:
      • Add (Name As String, IDBranch As String, FontAwesoneSymbol As String, Color As Int, ListLeaf As String()) As String
      • AddBranch (Name As String, IDBranch As String, IDParent As String, FontAwesoneSymbol As String, Color As Int) As String
      • AddLeaf (Name As String, Info As String, IDBLeaf As String, IDParent As String) As String
      • AddLeafOnTop (Name As String, Info As String, IDLeaf As String, IDBranch As String) As String
      • 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.
      • 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
      • SetLeaf (IDLeaf As String, NewName As String, NewInfo As String) As String
      • Sort (Ascending As Boolean) As String
    • Properties:
      • BranchTextColor As Int
      • Height As Int
      • ItemHeight As Int
      • LeafTextColor As Int
      • Left As Int
      • OpenOnlyOneBranch As Boolean
      • Top As Int
      • Width As Int


Preview.gif
 

Attachments

Last edited:

iz0ndg

Member
Licensed 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
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

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

Unobtainius

Member
Licensed 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
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

Member
Licensed 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
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

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

Unobtainius

Member
Licensed User
Works well, nice job ;)
 

Star-Dust

Expert
Licensed User
Update 0.03 improved animation
 

Unobtainius

Member
Licensed User
subtle, but nice.
 

Unobtainius

Member
Licensed 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
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

Member
Licensed 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
 

Star-Dust

Expert
Licensed 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