Welcome!

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

Reply
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: HorizontalFieldManager Problem

Should i add label directly to screen or to verticalfieldmanager which is parent of all hfms and vfms?
Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: HorizontalFieldManager Problem

When you add it to a MainScreen, you are effectively adding to a VFM that the MainScreen manages.

 

This and more is covered in detail here:

http://supportforums.blackberry.com/t5/Java-Development/MainScreen-explained/ta-p/606644

 

If you have a normal VFM, that you add to the MainScreen, then that will work too, i.e. you can add to that.  But remember both this VFM and the MainScreen must not scroll horizontally. 

Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: HorizontalFieldManager Problem

As i am adding fields dynamically. Can i set width of manager according to fields that are getting added in the manager?
Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: HorizontalFieldManager Problem

I'm not sure about a VerticalFieldManager, but a HorizontalFieldManager will just expand to the width required for the Fields you add.  I suspect a VFM might as well, but I've never tried that.

 

Give it a try and tell us if you have problems. 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: HorizontalFieldManager Problem


JoVinz wrote:
As i am adding fields dynamically. Can i set width of manager according to fields that are getting added in the manager?

The built-in managers, such as VerticalFieldManager and HorizontalFieldManager, always relayout properly when the fields are added to them. So your HorizontalFieldManager will recalculate its width and virtual width with the addition of each field and will scroll accordingly.

 

The cost of relayout is not high until you get to some hundreds of fields...

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: HorizontalFieldManager Problem

OK..i get your point. But if its as u said, Then why i am getting infinite Horizontal scroll?
thank you.
Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: HorizontalFieldManager Problem

Putting this bluntly, because you have coded something incorrectly.  Most likely you have added something with USE_ALL_WIDTH.  Alternatively you have created your own Manager and you do not set the extents correctly. 

 

To find this problem, as I think I have suggested before, I recommend that you use the typical debugging technique of making things 'standard' and then slowly changing things until they break.  Then you know what change broke the code.

 

In your case, start with just a standard MainScreen, with no style overrides, Add a LabelField as we have previously discussed, Make sure it fills the width of the screen and the text is centered.  Then add a standard HFM with something simple in it, like a normal LabelField.  Progress from there until the change you make to match what you want breaks it, i.e. Infinite scrolling sets in.  Then you know what caused the problem.  If you can't figure it out, you can ask about that specific issue.

 

But make sure you do the leg work.  If you add a Field or Manager and suddenly it becomes infinitely scrolling, then look at the code you have in the Manager or Field that might be related to this, specifically the style attributes and the layout or sublayout processing.  Change this and try again.  You will get to the stage that you know what bit of code is actually causing the problem and/or not doing what you expect.  So you can ask a focused question on a specific bit of code rather than a general "its not working" question. 

 

Doing this will help you understand what each of the things you change actually does, as well as finding your problem.

 

Good luck. 

Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: HorizontalFieldManager Problem

Thank you peter i will try as per your instructions.
Please use plain text.