B4A Library [Moved] CLVIndexScroller

scsjc

Well-Known Member
Licensed User
Longtime 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


B4X:
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(0, 0, 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
 

Attachments

  • xCustomListView with a CLVIndexScroller.zip
    17 KB · Views: 212

Brandsum

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


B4X:
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(0, 0, 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
Fixed. Use the updated one.
 
Top