B4J Question CustomListView Scrollbar Visibility

GuyBooth

Active Member
Licensed User
Longtime User
I have a CustomListView that sometimes only has two or three items in it and I don't want to show the scrollbar, and I want to widen the items to cover up the gap when the scrollbar isn't used. The gap disappears nicely if I uncheck the "Show Scroll Bar" property in the designer.
Other times it has 20+ items and I want to use the scrollbar, so I want it checked.

Is there a way to change the "Show Scroll Bar" property programmatically in B4J?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Yes.
B4X:
Sub SetCLVScrollBars(clv As CustomListView, Visible As Boolean)
   Dim nsv As ScrollPane = clv.sv
   If Visible Then
       nsv.SetVScrollVisibility("ALWAYS")
   Else
       nsv.SetVScrollVisibility("NEVER")
   End If
   Dim jo As JavaObject = clv 'ignore
   jo.SetField("_scrollbarsvisible", Visible)
   clv.Base_Resize(clv.AsView.Width, clv.AsView.Height)
End Sub
 
Upvote 0
Top