Android Question Scroll PCLV to specific index

B4X:
Sleep(0)   'do not forget this line
CustomListView1.ScrollToItem(CustomListView1.GetSize-1)  'use name you gave your customlistview variable, not PCLV
Thank you Mahares

"ArrayIndexOutOfBoundsException: length=0; index=-1", works if sleep(0) changed to sleep(100)
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Thank you Mahares

"ArrayIndexOutOfBoundsException: length=0; index=-1", works if sleep(0) changed to sleep(100)
It looks that you tried with an empty CLV.
B4X:
if CustomListView1.GetSize > 0 then CustomListView1.ScrollToItem(CustomListView1.GetSize-1)
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Better to have all the code outside the Activity_Create sub.
Move the code outside and just call it at the end of Activity_Create
Example
B4X:
Private Sub FillCLV
    'Fill the CLV
    Sleep(0)
    'Scroll to last item
End Sub
Call it from Activity_Create
B4X:
FillCLV
 
Upvote 0
Top