Scrollview Problem

Bill Norris

Active Member
Licensed User
Longtime User
On left side of activity is scrollview of labels, on right side of screen is an imageview. Left side labels are sized so that only one label is visible at the time. My goal is to have the imageview change as the labels are scrolled. Example,

When label1 is visible, image1 displays in the imageview.
As label 1 is scrolled up and out view, lable2 scrolls into view, and imageview changes to image2, etc, etc. The only way I know to do this is to continually monitor scrollviewposition, and use a series of if/thens to set the imageview picture based on scrollview position. This does not produce a smooth scroll, as everytime it moves at all, the scrollviewpositionchanege sub executes and causes the scrolling to be "choppy". Anybody got a better idea? I can't load all of the bitmaps onto the scrollview, as they are large and cause outofmemory errors.
 

kickaha

Well-Known Member
Licensed User
Longtime User
Not sure if this works but it is worth trying:

Set up a timer, with an interval of say 200 millisecs, and In the tick event put the code for displaying the imageview and disable the timer

In the scrollviewpositionchanged event disable and enable the timer.

This means that very little code is in the positionchanged event so it should run fast and the imageview is only updated 0.2 seconds after the scrollview as stopped scrolling.

You may want to play with the time for best effect.

If you try this, please let us know if it works as it is an interesting problem that others may come across.
 
Upvote 0

Bill Norris

Active Member
Licensed User
Longtime User
RE:

Kick -- that actually works pretty nice. I changed the timer interval to 1000, and I enable the timer in activity.start. Having it fire once per second doesn't appear to cause any issues, and the slight delay from the time the label scrolls up from the bottom and loading the image is not a problem. Every time the timer fires, the unfiltered log shows around 14% memory free, which is a whole lot more that it was when I loaded all of the images on startup. I'll be happy to upload a demo if interested.
 
Upvote 0
Top