B4A Library [B4X][XUI] CLVIndexScroller - xCustomListView fast scrolling index view

Discussion in 'Additional libraries, classes and official updates' started by Brandsum, Jun 29, 2019.

  1. Brandsum

    Brandsum Active Member Licensed User

    It's a class that adds a fast scrolling index view to xCustomListView. It has a dark and a light mode. You can show either alphabetic or numeric index and can change the index order.

    ezgif.com-optimize (3).gif
    Dependencies:
    1. xCustomListView
    2. XUI / jXUI
    Note:
    1. CLV items must be in sorted order.
    2. CLV items should have a label.
    3. CLVIndexScroller will scroll CLV depending upon the first label view of the CLVItem.
    4. After adding/removing CLV items remember to call CLVIndexScroller Refresh function.
    Usage:
    Code:
    Dim clv As CustomListView
    Dim clvIS As CLVIndexScroller

    For i=0 To 25
        
    For j=0 To 7
            clv.AddTextItem(
    Chr(i+65) & "-Lorem Ipsum" ,"")
        
    Next
    Next
    ''Initialize (clv As CustomListView, IndexTypeNumeric As Boolean, DarkTheme As Boolean, AscendingOrder As Boolean)
    clvIS.Initialize(clv,False,True,True)

    ''Change active item color
    clvIS.SetActiveColor(Colors.Green)


    ''Call update to refresh the active index while manual scrolling
    Sub clv_ScrollChanged (Offset As Int)
        clvIS.Update
    End Sub
    It's compatible with B4A, B4I and B4J.

    Update 1.01:
    Fixed crash issue when adding a panel instead of a text item.

    Next Update will be:
    1. Support for horizontal CLV
    2. Fixed theme and Popup theme
     

    Attached Files:

    Last edited: Jul 5, 2019
  2. scsjc

    scsjc Well-Known Member Licensed User

    Nice work, i try with CLVIndexScroller, and work perfectly when use AddTextItem, but i try to add with a item/panel and dont work.

    I attach the sample


    Code:
    Sub Globals
       
    Private clv1 As CustomListView
       
    Dim clvIS As CLVIndexScroller
       
    Private Label1 As B4XView
       
    Private CheckBox1 As B4XView
    End Sub
    Sub Activity_Create(FirstTime As Boolean)
       
    Activity.LoadLayout("1")
       
    'set the search items
       For Each line As String In File.ReadList(File.DirAssets, "colors.txt")
           
    Dim s() As String = Regex.Split(":", line)
           
    Dim Name As String = s(0)

         
           
    'AddTextItem    >>>   Work ok
           clv1.AddTextItem(Name , Name)

         
           
    'Add            >>>   Crash with a error
           'clv1.Add(CreateListItem(Name, clv1.AsView.Width, 60dip), Name)   

       
    Next
       clvIS.Initialize(clv1,
    False,True,True)
    End Sub
    Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
       
    Dim p As Panel
       p.Initialize(
    "")
       p.SetLayout(
    00, Width, Height)
       p.LoadLayout(
    "CellItem")
       Label1.Text = Text
       
    Return p
    End Sub
    Sub clv1_ScrollChanged (Offset As Int)
       
    'clvIS.Update
    End Sub
    Sub Clv1_ReachEnd
       
    Log("reach end")
    End Sub
    Sub clv1_ItemClick (Index As Int, Value As Object)
       clv1.AsView.BringToFront
       
    Log(Index)
    End Sub
     

    Attached Files:

  3. Brandsum

    Brandsum Active Member Licensed User

    Fixed. Use the updated one.
     
    Erel likes this.
  4. scsjc

    scsjc Well-Known Member Licensed User

    Thank you very much, it works perfectly.
    very good work
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice