VisibleRangeChanged is a godsend for my project as I was facing out of memory issues with my xCLV.
However, there is a problem as calling CLV.clear makes the app crash with the following exception:
It has nothing to do with VisibleRangeChanged as this never called after clearing the CLV. The app crashes as soon as CLV.Clear is called.
Note: The problem only occurs if the CLV has been scrolled before called Clear.
I have attached an example based on the original demo code.
However, there is a problem as calling CLV.clear makes the app crash with the following exception:
B4X:
customlistview_findindexfromoffset (B4A line: 370)
Dim CurrentItem As CLVItem = items.Get(Position)
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
at b4a.example3.customlistview._findindexfromoffset(customlistview.java:475)
at b4a.example3.customlistview._getfirstvisibleindex(customlistview.java:585)
at b4a.example3.customlistview._updatevisiblerange(customlistview.java:1620)
at b4a.example3.customlistview._scrollhandler(customlistview.java:1444)
at b4a.example3.customlistview._sv_scrollchanged(customlistview.java:1596)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$1.run(BA.java:325)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
It has nothing to do with VisibleRangeChanged as this never called after clearing the CLV. The app crashes as soon as CLV.Clear is called.
Note: The problem only occurs if the CLV has been scrolled before called Clear.
I have attached an example based on the original demo code.