Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
03-02-2011 03:36 PM
I have a screen form with two editFields and a button. What I want to do is to make them appears one under the other in the middle of the screen, like in this picture:
I tryed using 3 HorizontalFieldManager with
Manager.FIELD_VCENTER. inside a VerticalFieldManager created with Manager.USE_ALL_WIDTH style, but the fields appears on the top of the screen and they take all the width of the screen.
Solved! Go to Solution.
03-02-2011 04:05 PM
Since the main manager of your screen is VerticalFieldManager (you are using MainScreen, aren't you?), it will (understandably) ignore child fields' FIELD_VCENTER flags. It will, however, honor any horizontal alignment flags such as FIELD_HCENTER. However, FIELD_HCENTER does not play well with USE_ALL_WIDTH, so drop the latter. HorizontalFieldManager does honor its children's FIELD_VCENTER - you will have to use it to leverage this fact.
This might sound a little complicated at first, so I'll give you some more details:
1) Create your MainScreen with the explicit NO_VERTICAL_SCROLL style bit (important!)
2) Add a HorizontalFieldManager(USE_ALL_WIDTH | USE_ALL_HEIGHT) to the screen - let's call is bigHFM
3) Add a VerticalFieldManager(USE_ALL_WIDTH | FIELD_VCENTER) to bigHFM - let's call this new manager bigVFM
4) Create a HorizontalFieldManager(FIELD_HCENTER) - let's call it firstRow - and add it to bigVFM
5) Similarly, create a HorizontalFieldManager(FIELD_HCENTER) called secondRow and add it to bigVFM
6) Add LabelField("Label 1") and an edit field to firstRow
7) Add LabelField("Label 2") and another edit field to secondRow
8) Create a ButtonField("Button", FIELD_HCENTER) and add it to bigVFM
9) Run the application, look at the screen, tweak field margins if you feel like it and enjoy!
P.S.: albeit Field.setMargin is documented only in 6.0, it's been working like that since at least 4.2.0
03-02-2011 04:27 PM
Thanks for your answer, I made everything you told and now the fields are all vertically centered but labels don't appear and editFields takes all the width of the screen, how can I solve this?
03-02-2011 05:02 PM - last edited on 03-02-2011 05:26 PM by Taylarie
1) Are you adding labels before edit fields? It is important!
2) edit fields will indeed grab all width if left unchecked. I've already shown how to keep them contained in the following post - please take a look:
Post here is you still have problems.