Android Question CustomListView scrollbar not appearing

swabygw

Active Member
Licensed User
I'm using the CustomListView (not the one with the refresh, but the one here: https://www.b4x.com/android/forum/t...xible-list-based-on-scrollview.19567/#content ).

In the library file provided, the example works beautifully and the scrollbar is there.

I want to implement a new instance of the CustomListView programmatically, but the scrollbar doesn't appear when I do. Here's a simple example of the code that demonstrates the issue, which is just a slight modification of the example provided in the library file:

B4X:
    Sub Globals
      Private clv1 As CustomListView
      Private clv2 As CustomListView
      Private Label1 As Label
      Private Button1 As Button
      Private CheckBox1 As CheckBox
      Dim ScrollView_1 As CustomListView
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
      'Activity.LoadLayout("1")
      'Activity.RemoveViewAt(1)
      'Activity.RemoveViewAt(0)
      If FirstTime Then
        ScrollView_1.Initialize(Me, "ScrollView_1")
        Activity.AddView(ScrollView_1.AsView, 0, 50dip, 100%x, 100%y)
      End If
      ScrollView_1.AddTextItem("Aaaa", "a")
      ScrollView_1.AddTextItem("Aaaa" & CRLF & "Bbbb", "b")
      ScrollView_1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc", "c")
      ScrollView_1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc" & CRLF & "Dddd" , "d")
      ScrollView_1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc" & CRLF & "Dddd" & CRLF & "Eeee", "e")
      'clv1.AddTextItem("Aaaa", "a")
      'clv1.AddTextItem("Aaaa" & CRLF & "Bbbb", "b")
      'clv1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc", "c")
      'clv1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc" & CRLF & "Dddd" , "d")
      'clv1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc" & CRLF & "Dddd" & CRLF & "Eeee", "e")
      'For i = 1 To 10
      ' clv2.Add(CreateListItem($"Item #${i}"$, clv2.AsView.Width, 70dip), 70dip, $"Item #${i}"$)
      'Next
    End Sub
 

DonManfred

Expert
Licensed User
I guess the 5 items are showed up in the activity. No scroll needed as you dont have too much items for the screen...
Add more items and i guess the scrollbar will appear
 
Upvote 0

swabygw

Active Member
Licensed User
That's it, I think. I was experiencing the same behavior where I'm using the CLV in a bigger project where the items, which have varying heights, slide up and down. I think, now, that the when the item is in motion, the CLV may, or may not, know whether to add the scrollbar. Is there a way to manually (i.e., programmatically) force the appearance of the scrollbar?
 
Upvote 0

swabygw

Active Member
Licensed User
Okay - one last query: what is the condition that makes the scrollbar appear? For example, is it when the sum of the height of the items exceeds the height of the CLV's panel? Or, for another example, when the sum of the heights of the items exceed the vertical length of the parent view holding the CLV? Or, something along those lines maybe...
 
Upvote 0
Top