If the list of items to show has become empty after selecting from a db - there is a trouble with PreOptimizedCLV that has PCLV.ShowScrollBar = true.
Touching the scrollbar gives error
Error occurred on line: 165 (PreoptimizedCLV)
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:411)
...
And it's unclear how to avoid it, setting PCLV.ShowScrollBar = false - does not work.
B4X:
PCLV.Initialize(Me, "PCLV", CustomListView1)
If curPics.RowCount > 0 Then
For i = 1 To curPics.RowCount Step 4
curPics.Position = i
PCLV.AddItem(height, xui.Color_White, CreateMyImageData(i))
Next
PCLV.ShowScrollBar = True
PCLV.ExtraItems = 3
PCLV.Commit
Else
PCLV.ShowScrollBar = False
PCLV.Commit
ToastMessageShow("Empty list", False)
End If
I have a similar code but I use resultset and it works. Here is my code for my case:
B4X:
If rs.RowCount>0 Then
Do While rs.NextRow
PCLV.ShowScrollBar = True
Dim CNT As ColorNameType
CNT.Initialize
CNT.LabelText =rs.GetString("ColorName")
CNT.LabelNum =rs.GetString("ColorNum")
PCLV.AddItem(75dip, XUI.Color_Magenta, CNT)
Loop
Else
Log("No records found")
PCLV.ShowScrollBar = False
End If
rs.Close
I thought you are posting a project for us to check, but all you did is post a copy of the Preoptimized lib. That does not help. Note I am using the internal b4xlib 1.21
I posted the lib, setting PCLV.ShowScrollBar is not enough - PCLV.Commit is also required.
And i have the error at "B4XSeekBar1_TouchStateChanged" event if the list is empty if to touch the seekbar.
PCLV is nothing but an extension to xClv. It is automatically refreshed if I understand you correctly.
Have you read these important remarks from Erel:
The item layout should have a transparent background.
Better to remove AutoScaleAll and set the animation duration to 0 in the item layout.
The list should scroll very smoothly in release mode.
Make sure that "Show Scrollbar" option is unchecked in CLV custom properties.
PCLV.pnlOvarlay is the panel that hides the list when it fast scrolls. PCLV.lblHint is the label that appears. Both can be customized.
You can change the seek bar interval by setting PCLV.NumberOfSteps, before calling PCLV.Commit. The default value is 20. Don't set it to be too high as it will be difficult for the user to select a specific point.
This is a cross platform class that extends xCustomListView and makes it "lazier". Lazy loading is explained here: https://www.b4x.com/android/forum/threads/b4x-xui-customlistview-lazy-loading-virtualization.87930/#content and here...
www.b4x.com
If you still need help, post your project or wait for Erel to read this post and educate both of us.