Android Question ScrollView Position

I'm developing an application that uses a ScrollView with a panel inside where several elements are added (buttons, labels, etc) and that simulate a TreeView. At some point I need to update the text visualization. Then the items are deleted and replaced with their new information, but it's just an update, the same items will be there. Then I needed to memorize the position of the scrollview before the update and after its new filling, resume viewing at the same point.

I saw some examples on the forum. Tried with ScrollToNow and ScrollPosition... Nothing works. Any idea?
 
The structures are all redone (panels and other objects). This is because it is data read from a database with remote sync, which, despite being rare, may present some change in its structure made from a computer or other mobile device. Thus, a routine that builds the structure from scratch is used for this update, ensuring data integrity. My idea then is to scan the items and see if the desired one is still there, calculate its Y position and place the scroll on it. But it does not work. Neither ScrollPosition nor ScrollToNow works!
 
Upvote 0
Why does the scroll position change when you update the items?

I found the problem! When I tried to resume the scrollview position, it still wasn't mounted, even though the code was executed (because of asynchrony). Placing a DOEVENTS before the position definition worked. Then replace it with a Sleep(0). It keeps working, but without it doesn't work. Any suggestions for a better code or is it ok to use sleep(0)?
 
Upvote 0
Top