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


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.


Reply
Developer
Posts: 60
Registered: ‎08-20-2009
My Device: Not Specified
Accepted Solution

Custom space for ButtonFields:

I am new-bie, wanna provide space for two buttons. For ex: I have two buttons such as A and B. I code such a way that 'FieldListener' and add(xxx)' does that thing.

If i want to provide space between button A and B, how to do that? May be, button A can be on top and button B can be on bottom of the screen.

 

Clave.

Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: Custom space for ButtonFields:

You can use setMargin() for this purpose.

Try something like this:

 

ButtonField topButton = new ButtonField( "Top Button"); int topEmptySpace = ( Display.getHeight() - topButton.getPreferredHeight() - 10 /*10 for safe margin*/) ; ButtonField bottomButton = new ButtonField( "Bottom Button"); bottomButton .setMargin(topEmptySpace, 0, 0, 0); this.add(topButton); this.add(bottomButton);

 

Regards

Bikas

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

Re: Custom space for ButtonFields:

Hi,

 

As bikas suggested setMargin() is a better way of doing ,there one otherwork around also have a look at this thread

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=28663&query.id=20...

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

Re: Custom space for ButtonFields:

thanks all. I'll try.
Developer
Posts: 60
Registered: ‎08-20-2009
My Device: Not Specified

Re: Custom space for ButtonFields:

Hi,

 

When i run this sample piece of code, it reports 'cannot find symbol 'Display'  from 'Display.getHeight()'?

 

thanks.

 

clave.

 

 

Developer
Posts: 60
Registered: ‎08-20-2009
My Device: Not Specified

Re: Custom space for ButtonFields:

Ok. I added import as 'import net.rim.device.api.system.Display;' and no compilation error found.

But button is not showing up in the bottom space. I have total four buttons, Btn1, Btn2, Btn3 and 'Home' button. I want 'Home' button to be placed bottm, other buttons can be upper portion one by one. 

I tried the same sample piece of code but 'Home' button is not showing in the bottom instead it shows normally down after the third button.

 

Could somone review it?

       

       ButtonField homeBtn= new ButtonField("Home", ButtonField.CONSUME_CLICK);

 

        int topEmptySpace = ( Display.getHeight() -  Btn1.getPreferredHeight() - 10 /*10 for safe margin*/) ;
        homeBtn.setMargin(topEmptySpace, 0, 0, 0);
        homeBtn.setChangeListener(listner);

        add(homeBtn); 

 

clave.

Highlighted
Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: Custom space for ButtonFields:

Try like this:

 

ButtonField btn1 = new ButtonField("Btn1"); ButtonField btn2 = new ButtonField("Btn2"); ButtonField btn3 = new ButtonField("Btn3"); HorizontalFieldManager hfmTop = new HorizontalFieldManager(); hfmTop.add(btn1); hfmTop.add(btn2); hfmTop.add(btn3); ButtonField btnHome = new ButtonField("Home"); HorizontalFieldManager hfmHome = new HorizontalFieldManager(); hfmHome.add(btnHome); int topEmptySpace = ( Display.getHeight() - (hfmTop.getPreferredHeight() + btnHome.getPreferredHeight() + 10) ) ; hfmHome.setMargin(topEmptySpace, 0, 0, 0); this.add(hfmTop); this.add(hfmHome);

 

Regards

Bikas

 

Developer
Posts: 60
Registered: ‎08-20-2009
My Device: Not Specified

Re: Custom space for ButtonFields:

Appreciate your help Mr.Bikas.