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: 42
Registered: ‎12-04-2008
My Device: Not Specified
Accepted Solution

Display fields in a line

How can show two EditFields or two DateFields  in a row and add an icon in a LabelField.Could anyone provide me some code examples? Thanks in advance.
Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: Display fields in a line

You can use paint() method of labelfield to drawimage on a labelfield and use HorizontalFieldManager to display two label fields in a line.

 


Press the kudos button to thank the user who helped you.

If your problem was get solved then please mark the thread as "Accepted solution".

 

 

Deepesh Gupta
New Developer
Posts: 17
Registered: ‎02-06-2009
My Device: Not Specified

Re: Display fields in a line

 Hi,

 

Try this code. It may help you.

 

 

final class ManagerScreen extends MainScreen

{

    public ManagerScreen()

    {

     HorizontalFieldManager hfm1 = new HorizontalFieldManager();

     HorizontalFieldManager hfm2 = new HorizontalFieldManager();

     

     LabelField lf1 = new LabelField("Search",EditField.FIELD_HCENTER);

     add(lf1);

    

     LabelField lf2 = new LabelField(" City : ",EditField.FIELD_RIGHT);

     EditField ef2 = new EditField("","",6,EditField.NO_NEWLINE);

    

     LabelField lf3 = new LabelField(" Name : ",EditField.FIELD_RIGHT);

     EditField ef3 = new EditField("","",6,EditField.NO_NEWLINE);

 

    

     hfm1.add(lf2);

     hfm1.add(ef2);

     add(hfm1);

    

     hfm2.add(lf3);

     hfm2.add(ef3);

     add(hfm2);

     

       

    }

 

 

With Regards,

Vimal 

Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Display fields in a line

Hii,

You cando one thing you can add your image in BimapField and then add both you Bitmapfield and DataField in one flowFieldManager of HorizontalFieldManager and then add this magaer on to the screen.

 

Please let me know if you have any query.

 

Regards,

Rajat Gupta.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Display fields in a line

Hi ,

Please find the code for your problem.

 

Let me know if this solved your problem or not.

 

NOTE: Please include an appropriate *.png

 

public void drawComponent(){ HorizontalFieldManager ManagerDataField = new HorizontalFieldManager(); HorizontalFieldManager ManagerBitMap = new HorizontalFieldManager(); HorizontalFieldManager ManagerBag = new HorizontalFieldManager(); Bitmap objDrawingImage = Bitmap.getBitmapResource("crossSign.png"); BitmapField objHeader = new BitmapField(objDrawingImage,BitmapField.FIELD_LEFT); BasicEditField objText = new BasicEditField("NAME:","Red"); ManagerBitMap.add(objHeader); ManagerDataField.add(objText); ManagerBag.add(ManagerBitMap); ManagerBag.add(ManagerDataField); add(ManagerBag); }

Regards,

Rajat Gupta.

 


 If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish

 

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Display fields in a line

[ Edited ]

The answer, as you will have figured out from the above, is to use a HorizontalFieldManager - which will layout your Fields Horizontally.  The problem is that the HorizontalFieldManager (HFM) asks the Field it is laying out how much space they need.  Some Field will always ask for the full width, some don't.  It is possible for you to override the amount a Field will ask for, by overriding its layout method and called setExtent() with specific parameters.  This is the method I typically use. 

 

Note that the same comments apply to the FlowFieldManager.

 

However I beleive, in later OS Levels, you can achieve the same restriction, by including the Field in another Manager which restricts the Field width.  I note that the sample given above has done this using HorizontalFieldManager, I thought people generally used VerticalFieldManager.  As noted, I'm not familiar with this method.  However I would suggest you search round this forum for other entries that ask similar questions for other options.

 

You might find this one useful:

 

two radio buttons on a single line

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=14266

 

You might also find the following useful:

 

How To - Create custom fields
Article Number: DB-00120

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

 

Edited to fix a few typos.

Message Edited by peter_strange on 03-09-2009 09:53 AM
Highlighted
Developer
Posts: 57
Registered: ‎01-29-2009
My Device: Not Specified

Re: Display fields in a line

Here EditField consumes the whole width by default, placing the label of the left, if there is not enough space it concumes a second line.
you can change the default layout by overwriting getpreferredwitdth() in the field class or using a custom layout manager.

So if you can change the size of EditField ass per your requirement You can do it by HorizontalFieldManager.

 

All the best

Vaikunth