Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

blackberry appworld like scrolling feature

I have an HFM where i have two images each occupying the entire screen.Now suppose i start to scroll,i want that the image whose portion is more visible in the screen that one should occupy the screen,just like blackberry appworld

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: blackberry appworld like scrolling feature

Similar questions have been asked in the past, search the forum.


The simple solution is to set focus on the item you want to occupy the whole screen.  The Managers will make sure that all of the focusable Field is visible, so you make your entire image focusable, then it should all display.  You might want to override drawFocus on the Image to make sure it does not attempt to draw anything visible.


Then the question is which Field do you put focus on to, given you have multiple  images like App World. 


One easy way round this is to have a Scroll Listener for the HFM containing the Fields.  Have it start a Thread (only one Thread) when scroll movement is detected, and this Thread will monitor the current HFM scroll position frequently.  When it looks like t has stopped moving, or is not moving very quickly, it can calculate based on the virtual width o the HFM and the current scroll position, which item should be in focus, and set the focus on that.  if that item already has focus, then the Thread has done its job and can stop. 


There are more complicated ways of doing this, which I suspect App World uses


And then of course there is PictureScrollField, which is probably the first thing you you should look at.