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
New Developer
mico
Posts: 20
Registered: ‎04-11-2009
My Device: Not Specified
Accepted Solution

How to build nested managers?

Hello, forum

 

I have a custom VerticalFieldManager with this sublayout method:

 

 

protected void sublayout( int maxWidth, int maxHeight ) { int iNumFields = getFieldCount(); int iYPos = 7; for (int i = 0; i < iNumFields; i++) { Field fField = this.getField(i); setPositionChild(fField, 10, iYPos); layoutChild(fField, maxWidth-10, maxHeight); iYPos = iYPos + fField.getHeight(); } setExtent(Display.getWidth(), getPreferredHeight());}

 

 And of course if I put another Manager based instance into it using 'add' method I get nothing, because there is no manager layout processing here. How to do that?

 

Thanks 

 

Please use plain text.
Developer
simon_hain
Posts: 16,042
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to build nested managers?

a manager is a field. but unless the manager has a size, either because fields are added or because you set one, it does not need space and thus does not get layouted.
----------------------------------------------------------
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
Please use plain text.
New Developer
mico
Posts: 20
Registered: ‎04-11-2009
My Device: Not Specified

Re: How to build nested managers?

Thanks for you quick reply, Simon.

 

But what if I have usual VerticalFieldManager testvfm = new VerticalFieldManager();

I just put these into it:

 

testvfm.add(new LabelField("test"));testvfm.add(new LabelField("tset"));

 And that works when I add it into the screen but not if I add it into that manager I've described above. 

 How can I set height to this  testvfm so my 'sublayout' method will know that it is not zero height.


 

Please use plain text.
New Developer
mico
Posts: 20
Registered: ‎04-11-2009
My Device: Not Specified

Re: How to build nested managers?

Also, here is the getPreferredHeight method:

 

public int getPreferredHeight() { int iNumFields = getFieldCount(); int h = 14; for (int i = 0; i < iNumFields; i++) { Field fField = this.getField(i); h += fField.getHeight(); } return h; }

 

 And for usual fields like LabelField or TextField this custom class works fine.

 

Please use plain text.
New Developer
mico
Posts: 20
Registered: ‎04-11-2009
My Device: Not Specified

Re: How to build nested managers?

Sorry, that mentioned sublayout method works fine for managers.
Please use plain text.