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
Regular Contributor
sheetaloswal
Posts: 59
Registered: ‎03-06-2012
My Device: 9700

Issue with flowfieldmanager

Hi  All,

 

    I am trying to use a flowfieldmanager for displaying the labelfields in the next line when width of the screen is reached.I have the custom class like


import net.rim.device.api.system.Display;
import net.rim.device.api.ui.container.HorizontalFieldManager;

public class CustomHFM extends HorizontalFieldManager {

    private long style;

    public CustomHFM(long style) {
        super(HORIZONTAL_SCROLL);
        style = style;
    }

    public int getPreferredWidth() {
        return Display.getWidth();
    }

    // define height
    public int getPreferredHeight() {
        return 40;
    }

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(getPreferredWidth(), getPreferredHeight());
        setExtent(getPreferredWidth(), getPreferredHeight());
    }

}

 

And i am using this has

 

CustomHFM horizontalFieldManager_left15 = new CustomHFM(
                Manager.HORIZONTAL_SCROLL);

    for (int x = 0; x < event15.size(); x++) {

                 horizontalFieldManager_left15.add(labelField15[x]);
        }

vfm.add(horizontalFieldManager_left15);

this.add(vfm);

 

This just shows only two labelfields here the loop repeat for 5 times ,if i change the flowfieldmanager to HFM it works fine.What is the issue here?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Issue with flowfieldmanager

using setExtent after super.sublayout is a bad idea.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
sheetaloswal
Posts: 59
Registered: ‎03-06-2012
My Device: 9700

Re: Issue with flowfieldmanager

If its a bad idea then what should be used and what is the cause of problem?
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Issue with flowfieldmanager

You subject says FlowFieldManager, the supplied code using HorizontalFieldManager.  can we see the failing code please?

 

Re Simon's comment, the idea of layout is that it will set the required size.  By issuing a setExtent, you are actually saying, regardless of the layout, thi sis how much Screen relestate this Manager will take up.  Is that valid?  Typically not.

 

Re recommend that you review this:

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749

 

and this

http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

Regular Contributor
sheetaloswal
Posts: 59
Registered: ‎03-06-2012
My Device: 9700

Re: Issue with flowfieldmanager

It was a type i am using FlowFieldManager there
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Issue with flowfieldmanager

I thought that might be the case, but the comments in my Post sitll all stand.  Please re-read and respond.  I suggest you review the setExtent code before you do so however.