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
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified
Accepted Solution

Align field right in HFM

Hello,

I have 2 fields in a HFM.

I want the first one to be aligned on the left and the second one on the right.

 

Can you give me a sample code to do that please ?

 

I already tried with several VFM in HFM but maybe I got the style wrong cause nothing is working

 

thanks 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Align field right in HFM

What sort of Fields are these?
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Align field right in HFM

One RIchTextField on the left and one ButtonField which I'd like to put on the right
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Align field right in HFM

textfields of all kind "want" the full width. you can overwrite the getPreferredWidth method of your RichTextField and you will be able to add a button next to it.
----------------------------------------------------------
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
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Align field right in HFM

[ Edited ]

No but the result I want is to align the button to the right of the screen, like that:

 

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

| TEXTFIELD          button|

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

 

I cannot get the button to align to the riight

Message Edited by yann247 on 05-05-2009 10:05 AM
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Align field right in HFM

you can always use absolute layout:
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/How_To_-_Create_a_custom_layout_manager...
----------------------------------------------------------
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
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Align field right in HFM

I'd prefer not to use this as the result will differ depending on the blackberry model (my app has to run on old BB too, and font size, resolution and everything differs).

 

Nothing else? 

Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Align field right in HFM

Any idea?

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Align field right in HFM

As Simon said, the problem is that the Text Fields always want to know how wide they can be, so that they can do Word wrap on the displayed text.  So you are going to specify the Width of that Field.  However that can cause a problem - unless you know how wide the Button is, you don't know how much width is left for the Text Field.  And it could vary depending on the Font and so on.  So we have a chicken and egg here, which as far as I know, none of the default Managers can cope with.

 

So you are going to have to determine the Button width, and use that to subtract from Display.getWidth(), so you know how wide to make the Text Field.

 

Note things start getting a little hairy when you start having to cope with orientation changes on Storm devices, but this is all perfectly feasible.

Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Align field right in HFM

Ok, i see.

how can i determine the size of the button dynamically?