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
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Objectchoicefield align center

Hi,

 

I'm trying to center objectchoicefield but couldn't . Tried to put it in horizontalmanager and center the manager.Tried to use objectchoicefield.field_hcenter and drawstyle.hcenter both but nothing is working.Please help

Rujuta Trivedi
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Objectchoicefield align center

create a custom layout.
see
http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...
----------------------------------------------------------
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
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: Objectchoicefield align center

tried that giving width to manager but didn't work

Rujuta Trivedi
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10

Re: Objectchoicefield align center

Try Using this code it will help u make Objectchoicefield centred

ObjectChoiceField objectChoiceField = new ObjectChoiceField("", choices,0, ObjectChoiceField.FIELD_HCENTER )
{
protected void setExtent(int width, int height)
{
super.setExtent(150, 50);
}
};
add(objectChoiceField);
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Objectchoicefield align center

[ Edited ]

Please do not ever override setExtent unless you really have no choice. But I have never had to do this to achieve the effect I wanted and can not actually think of a reason to do so. 

 

I say again, do NOT override setExtent. 

 

ObjectChoiceField.FIELD_HCENTER can be used to center an ObjectChoiceField - you just need to make sure the Manager that contains this Field is actually also using the full width of the area it has available to it.  See more here:

 

http://supportforums.blackberry.com/t5/Java-Development/Aligning-labelfield-in-the-centre-of-a-Horiz...