Android Question CustomListView floating titles - button

Discussion in 'Android Questions' started by kisoft, May 9, 2019.

  1. kisoft

    kisoft Active Member Licensed User

    Hi
    I would like to use this very nice solution..
    .https://www.b4x.com/android/forum/threads/xui-customlistview-with-floating-titles.87935/#content
    How to add additional elements? , for example, a button, image, to the drop-down list.

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("1")
        pnlTitle.Visible = 
    False
        pnlTitle.SetLayoutAnimated(
    000, CLV1.AsView.Width, TitleHeight + DividerHeight)
        pnlTitle.LoadLayout(
    "CellTitle")
        AddTitle(
    "Title #AAA")
        
    For i = 1 To 10
            CLV1.AddTextItem(
    $"A) Item #${i}"$"")
        
    Next
        AddTitle(
    "Title #BBB")
        
    For i = 11 To 21
            CLV1.AddTextItem(
    $"B) Item #${i}"$"")
        
    Next
        AddTitle(
    "Title #CCC")
        
    For i = 22 To 32
            CLV1.AddTextItem(
    $"C) Item #${i}"$"")
        
    Next
        CLV1_ScrollChanged(
    0)
    End Sub
     
  2. kisoft

    kisoft Active Member Licensed User

    HI
    I think I succeeded. It works somehow. Unfortunately, the list is slowly starting up.

    Code:
    Sub Activity_Create(FirstTime As Boolean)
       
        
    Activity.LoadLayout("1")
        pnlTitle.Visible = 
    False
        pnlTitle.SetLayoutAnimated(
    000, CLV1.AsView.Width, TitleHeight + DividerHeight)
        pnlTitle.LoadLayout(
    "CellTitle")
        AddTitle(
    "Title #AAA")
        
    For i = 1 To 10
        CLV1.Add(CreateListItem(
    100%x,10%y),i)
        
    Next
        AddTitle(
    "Title #BBB")
        
    For i = 11 To 21
           CLV1.Add(CreateListItem(
    100%x,10%y),i)
        
    Next
        AddTitle(
    "Title #CCC")
        
    For i = 22 To 32
            CLV1.Add(CreateListItem(
    100%x,10%y),i)
        
    Next
        CLV1_ScrollChanged(
    0)
     
    End Sub

    Sub CreateListItem(Width As Int, Height As Int) As Panel

        
    Dim p As B4XView = xui.CreatePanel("")
        p.SetLayoutAnimated(
    000, Width, Height)
        p.LoadLayout(
    "2")
        
    Return p

    End Sub
     
    Last edited: May 9, 2019
  3. Erel

    Erel Administrator Staff Member Licensed User

    Clean the project (Ctrl + P) or test it in release mode. It should be fast.
     
  4. kisoft

    kisoft Active Member Licensed User

    Scrolling works smoothly, but the activity with the list opens after 4s.
     
  5. AnandGupta

    AnandGupta Active Member Licensed User

    I think some lazy loading logic may help here, as you are creating the layout of all the items at first.

    Regards,

    Anand
     
  6. kisoft

    kisoft Active Member Licensed User

    I tried to move the Activity Create part to another sub, but this only slows down the loading of the layout.
     
  7. Rubsanpe

    Rubsanpe Member Licensed User

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