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: 24
Registered: ‎01-30-2011
My Device: BlackBerry Bold 9700

HorizontalFieldManager Scrolling Horizontally

Hey there,


I am trying to create a screen (extending MainScreen) containing two horizontal managers with horizontal scrolling.. withing the managers there are other custom managers including bitmapfields and labelfields. I've set the bitmapfields to Focusable and overriden the onFocus function to change the background color when gained focus. I can scroll vertically but the view and the scrolling are not in sync as well as the horizontal scrolling within the fields doesn't work at all...any advice?BB_Layout.jpg

Trusted Contributor
Posts: 151
Registered: ‎06-17-2010
My Device: Curve 8900
My Carrier: Vodafone

Re: HorizontalFieldManager Scrolling Horizontally

hey bilalk89,


are you set layout to the Horizontal manager in which you add the bitmapfield?


if yes, then you can not set that manager property as HORIZONTAL_SCROLL and FOCUSABLE.





HFM3 = new HorizontalFieldManager(HORIZONTAL_SCROLL |FOCUSABLE){
  protected void sublayout(int maxWidth, int maxHeight) {
  maxHeight = 200;
  super.sublayout(maxWidth, maxHeight);
  setExtent(maxWidth, maxHeight);




to solve this problem,


you have to take another HorizontalFieldManager with not override method and set property HORIZONTAL_SCROLL  and FOCUSABLE etc..

and after that add HFM3_1 into HFM3..





HFM3 = new HorizontalFieldManager(){
  protected void sublayout(int maxWidth, int maxHeight) {
  maxHeight = 200;
  super.sublayout(maxWidth, maxHeight);
  setExtent(maxWidth, maxHeight);



HFM3_1 = new  HorizontalFieldManager(HORIZONTAL_SCROLL |FOCUSABLE);





this will work for you... Enjoy...



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.


Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: HorizontalFieldManager Scrolling Horizontally

First of all, I trust you did specify HORIZONTAL_SCROLL flag in your HorizontalFieldManagers. Just asking.

Second - what do you mean "view and scrolling are not in sync"? What do you see? What exactly feels not intuitive?

Third - horizontal scrolling within fields inside HFM? This is not an easy proposition - you will have to override sublayout in those inner managers to limit their width, as well as create them with HORIZONTAL_SCROLL flag as well. Can you show the relevant sublayout() code?


Meanwhile, since you have many scrolling managers and can travel between them, take a long look at NO_SCROLL_RESET style flag in managers. Depending on what exactly you are trying to achieve, you might or might not need it.

please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
New Developer
Posts: 11
Registered: ‎12-17-2010
My Device: Not Specified

Re: HorizontalFieldManager Scrolling Horizontally

Hi Bilak,

The implementation is very simple. Where ever you want to implement horizontal scrolling add NullField to the end of particular HorizontalFieldManager and one  NullField to the main VerticalFieldManager where you are adding all the managers.


I hope this will the implementation as u mentioned.