Problem with Scroll Position

Bill Norris

Active Member
Licensed User
Longtime User
I have a scrollview with about 15 items. User selects and item which loads the appropriate activity. I store the scrollposition of the scrollview in a global variable, so that when user comes back to the activity, I can have the scrollview be at the same scrollposition it was originally, rather than going back to the top. For some reason, even though the correct scrollposition is being stored and properly retrieved during acitivy_create, the scroll view always goes back the top (scrollposition of zero). During debug, if I put a breakpoint anywhere in the activity_create code, the scrollview will set at the correct position that I have saved, but without the break point, it goes back to the top every time. BTW, I am using activity_finish by necessity for other reasons, so leaving the acivity in memory is not an option.
 

Bill Norris

Active Member
Licensed User
Longtime User
RE:

The position is indeed stored in a process global. Simply adding the doevents and then again the line afterward to set the position solved the issue.
 
Upvote 0

texwillerx

Member
Licensed User
Longtime User
I had the same problem. One line didn't solve my problem. Only after I put the two lines in a for loop solved the problem (i=1 to 10).
 
Upvote 0

texwillerx

Member
Licensed User
Longtime User
Erel, thank you for this beautiful code.

Unfortunately, it works for all cases, except for the first setting of the pos when the program starts.

I use 5 as the for loop index, it works fine, then.

Best Regards

PS: Don't you ever sleep?
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
B4X:
ScrollView1.Position = p
DoEvents
ScrollView1.Position = p

Works great for me too , i had the same problem as Bill
in activity resume scrol.request focus returns false

It seems there is an issue with scrol position , the code works only first time app starts
 
Last edited:
Upvote 0
Top