Android Question Bug or my mistake in ScrollToItem?

darabon

Active Member
I have more than 20 items in xclv and want to scroll to the end of the list
I tested ScrollToItem and JumpTo but both function scroll clv to 18th item
Also, add sleep before this function but still have the same problem
I call the below function after add items to clv
What is the problem?

B4X:
Sub LoadMessages
    
    lvmessages.Clear
    messages = db_.GetGroupMessage(GroupID_)
        
    For i = 0 To messages.Size - 1
    
        Dim p As B4XView = xui.CreatePanel("")
        p.Color    =    Colors.Transparent
        p.SetLayoutAnimated(0, 0, 0, lvmessages.AsView.Width, 61dip)
        lvmessages.Add(p, messages.Get(i))
    
    Next
    
    If lvmessages.Size > 0 Then
        CallSubDelayed(Me,"Jump")
    End If
    
End Sub

Sub Jump
    Sleep(1500)
    lvmessages.ScrollToItem(lvmessages.Size-1)
End Sub
 

darabon

Active Member
The CallSubDelayed doesn't do anything useful. Simply call Jump.


What does it mean? Is the 20th item visible?
I use only Jump without CallSubdelayed but not working
No not visble and I have to scroll to end manual
I added 20 items to clv and want to jump to end or clv.size-1 but clv jump to clv.size-4 or clv.size-3
 
Upvote 0

darabon

Active Member
Leave my answer
I need to scroll clv to end (because my app is chat)
How do I scroll clv to end list?
I searched already in forum but my result is bad
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I use that after add items to clv, is that right?
Here is an example:
B4X:
Sub Button1_Click
    clv1.AddTextItem("darabon", "")
    Sleep(0)
    clv1.ScrollToItem(clv1.GetSize-1)
End Sub
You also need to make the title of your thread more descriptive , something like: Cannot ScrollToItem after Adding a Record to XClv
 
Upvote 0

darabon

Active Member
Here is an example:
B4X:
Sub Button1_Click
    clv1.AddTextItem("darabon", "")
    Sleep(0)
    clv1.ScrollToItem(clv1.GetSize-1)
End Sub
You also need to make the title of your thread more descriptive , something like: Cannot ScrollToItem after Adding a Record to XClv
Make a sleep for complete adding items and then jump to index?
 
Upvote 0

eric19740521

Member
Licensed User
Longtime User
Not perfect. But at least the job is done...

'bug,Automatically move to the next line
clvShow.AddTextItem("darabon", "")
Sleep(0)
clvShow.ScrollToItem(clvShow.GetSize-1)
'clvShow.ScrollToItem(clvShow.Size-1) 'Automatically move to the next line
clvShow.RemoveAt(clvShow.GetSize-1)
 
Upvote 0
Top