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
Contributor
Posts: 14
Registered: ‎04-14-2011
My Device: 9700
Accepted Solution

ButtonField and LabelField layout

Hi,

 

Im using a horizontal field manager for the bottom section of the screen i want to achieve the following with the components but finding it trick they end up next to eachother.

 

-----------------------------------------------

[Label]               [Label]           [button

[TextField]         [TextField]

-----------------------------------------------

 

I also have an issue where when i use the simulator for storm when i use the button once then again i get the menu, can i dissable this somehow ?

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

Re: ButtonField and LabelField layout

First of all - if you want this part on the bottom of the screen, use MainScreen and its setStatus method. More about it here:

MainScreen explained

 

I guess you already knew that, but decided to mention the article for completeness sake.

 

Now, for the second, more serious part: arranging your items. There are two distinct approaches to this problem:

1) Create your own layout manager. It may be as specialized as you want. The groundwork (or, more precisely, the main idea) of this approach is shown here:

Create a custom layout manager for a screen

Even though it might not be all that necessary here, learning this technique may prove very useful in the future. If nothing else, it will teach you a lot about the inner works of BlackBerry built-in managers. So do that as an exercise at least.

2) Use built-in layout managers (vertical for the whole section; two horizontal added to it, one for each "row") and field margins. You might not be able to position the fields exactly the way you want, but it will be close enough. Don't forget: even though Field.setMargin is documented in 6.0 only, it has been working like that since at least 4.2, so you can definitely use it to build for any reasonable version. In order to better understand how the margins work, read the OS 6.0 documentation on VerticalFieldManager and HorizontalFieldManager - they finally explain the issue in great detail.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 14
Registered: ‎04-14-2011
My Device: 9700

Re: ButtonField and LabelField layout

Hi,

 

I am having a small problem trying to place two BasicEditFields next to eachother it seems that only one is visible, even if i override thier preferredWidth to 30, the horizontal screen manager has more than 60 width.

 

Is there also some way to bring the label of the BasicEditField above the text area like so:

 

Label

[input]

 

Rather than:

Label[input]

 

 

Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook

Re: ButtonField and LabelField layout

If  you want layout like this

-----------------------------------------------

[Label]               [Label]           [button]

[TextField]         [TextField]

-----------------------------------------------

 

use

VerticalFieldManager say VFM

inside this

have two HorizontalFieldManager say HFM1 and HFM2

in HFM1 add label1, label2 and button

in HFM2 add textfield1 and textfield 2

add these two HFMs in VFM

add VFM to screen object

 

-Abhinav

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: ButtonField and LabelField layout

 


MC2011 wrote:

Hi,

 

I am having a small problem trying to place two BasicEditFields next to eachother it seems that only one is visible, even if i override thier preferredWidth to 30, the horizontal screen manager has more than 60 width.

 

Is there also some way to bring the label of the BasicEditField above the text area like so:

 

Label

[input]

 

Rather than:

Label[input]

 

 


 

For the BasicEditField explanation and an example of how to combat that, see this post:

editfield and checkboxfield on the same line

Everything said about EditField being width-hungry also applies to BasicEditField.


Putting label on top of input area is achieved extremely easily: add a LabelField and a label-less EditField to a VerticalFieldManager and you'll get the result.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 14
Registered: ‎04-14-2011
My Device: 9700

Re: ButtonField and LabelField layout

Thank you very much that worked like a charm what i did is the following:

 

1) Made my own CustomEditField extend the BasicEditField, from there i just overrode the layout as in that article.

2) To get the input box under the label what i did was add a "\n" escape character to the label field.

3) Added two CustomEditFields + a button in the horizontal field manager, i know this may not scale to resolution pritty well between devices but at the moment i am just learning.

 

What i need to do next is change the background colour of just the input area of the basiceditfield as soon as i find out how.

 

Thanks for all your answers.