Android Question Show last line added to xCustomListView?

Danamo

Member
Licensed User
Please forgive what is probably a dumb question with a simple answer, but I've searched these forums and couldn't find the answer...

How do I get an xCustomListView to show the very last line added? I have tried using
B4X:
clv1.ScrollToItem(clv1.Size-1)
and
B4X:
clv1.JumpToItem(clv1.Size-1)
but these only show close to the last line of text added, not actually the last line.

The ".size" parameter is the total number of items, and is a zero-based index, right? Because jumping to ".size" instead of ".size-1" causes an error.

What am I doing wrong?

For whatever it's worth, I am using the xCustomListView to display incoming messages in a chat application. I used xCLV instead of a regular Listview because the messages can be 3 or more lines of text on the screen and the xCLV automatically wraps the entire message into multiple lines.

If there is a better way to display the incoming messages besides using a Listview or xCustomListview I would be delighted to hear of it! Or how to ensure the last entry in the CLV is visible?

Thanks for any help you can give me.
 

Danamo

Member
Licensed User
Try:
B4X:
Sleep(0)
clv1.JumpToItem(clv1.Size-1)
Thank you very much for your response. The "Sleep" command works perfectly to solve the problem! I guess there needs to be a slight delay after adding a new line before jumping to it, to give it time to process the addition? Even though sleeping for 0 milliseconds is a pretty short nap, LOL.

I will definitely buy you a cup of coffee for helping me out.
 
Upvote 0
Top