03-08-2011 07:52 AM
Continuing this thread: http://supportforums.blackberry.com/t5/Java-Develo
The requirements have evolved.
I now need to save the position on the Screen where the user has scrolled to once the screen has been redrawn.
Specific Screens are relayed out and repainted based on a TimerTask. Once the Screen is redisplayed, I need to automatically reposition/scroll to the position the user was on the screen.
For example:
Ideally, I'd like to save the XYPoint and then reposition the Screen to the saved XYPoint - a little prototype needs to be done on my part, granted.
However, is there a better design or has anyone implemented this feature before on OS 5.0.0?
Thanks.
Solved! Go to Solution.
03-09-2011 06:21 PM
getVerticalScroll should help.
You might have to do this recursively depending on the number of Managers and their nesting, but that is how I would start.
The other option is to try to find the 'extent' of all the Fields, and it is possible to find out exactly where they are in the Display. From there you find out the one closest t the top, and then setFocus on that Field once you have relayed out.
Sounds like a bit of challenge. Good luck.
03-09-2011 11:52 PM
I have done this with a custom manager(s) using the vertical scroll offset recursively through the manager stack as suggested by Peter, but be mindful that you need not only the y scroll but the y position within the screen/manager to track the actual screen position versus the percieved one. Here is the code I use in my manager with my custom functions:
public final int getAbsoluteY(){
int absY = (getY()+drawY);
while( getManager() instanceof CustomLayoutManager ){
return absY + ((CustomLayoutManager)getManager()).getAbsoluteY() ;
}
return absY;
}