B4A Library CLVNested - Allows nesting CLVs

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jul 17, 2019.

  1. Erel

    Erel Administrator Staff Member Licensed User

    [​IMG]

    Putting a CLV inside another one will not work out of the box. The inner list will not be scrollable.

    CLVNested makes it possible.

    Limitations:

    - One list per item.
    - The user will not be able to interact with the inner list views.
    - Will not work with other extensions that "steal" the touch events such as CLVSwipe.

    Usage:

    1. Initialize the CLVNested object.
    2. Load the layout with the main list to nested.base.
    3. Set the main list with:
    Code:
    nested.CLV = CustomListView
    4. Add the items. If you want to add items with inner lists then you need to set the panel's tag to point to the list.

    Complete example:
    Code:
    Sub Globals
       
    Private CustomListView1 As CustomListView
       
    Private clvItem As CustomListView
       
    Private xui As XUI
       
    Private nested As CLVNested
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
       nested.Initialize(
    Activity)
       nested.base.LoadLayout(
    "1")
       nested.CLV = CustomListView1
       
    For i = 1 To 10
           CustomListView1.AddTextItem(
    $"*** TITLE (${i}) ***"$"")
           
    Dim p As B4XView = xui.CreatePanel("")
           p.SetLayoutAnimated(
    000100%x200dip)
           p.LoadLayout(
    "Item")
           p.Tag = clvItem 
    'must set the Panel tag like this
           FillInnerList
           CustomListView1.Add(p, 
    "")
       
    Next
    End Sub

    Sub FillInnerList
       
    For x = 1 To 10
           clvItem.AddTextItem(
    $"Item #${x}"$, x)
       
    Next
    End Sub
    Depends on ViewsEx library.

    Note that such solution is not required in B4i or B4J. The standard xCLV will suffice.

    Updates

    v1.10 - Adds support for nested horizontal CLVs.
     

    Attached Files:

    Last edited: Dec 5, 2019 at 7:56 AM
  2. Erel

    Erel Administrator Staff Member Licensed User

    v1.10 - Adds support for nested horizontal CLVs.
     
    Beja, vecino and LucaMs like this.
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