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
NitinPatel
Posts: 107
Registered: ‎10-06-2010
My Device: Not Specified
Accepted Solution

ObjectChoiceField: how to set the width of the dropdown window

[ Edited ]

Hi Guys,

 

How could you set the width of the DropDown window (which displays all choice items of your choice field)? The application automatically sets the width based on the width of the choice items.

 

Thank you

 

Nitin

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

Re: ObjectChoiceField: how to set the width of the dropdown window

 

no way to modify it. if you need it different create your own objectchoicefield, for example leveraging objectlistfield and popupscreen.

----------------------------------------------------------
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
NitinPatel
Posts: 107
Registered: ‎10-06-2010
My Device: Not Specified

Re: ObjectChoiceField: how to set the width of the dropdown window

Thank for your confirmation, you saved my time.

 

But that is a bad news. It  must be too much work to create own objectchoicefield.

 

Nitin

 

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

Re: ObjectChoiceField: how to set the width of the dropdown window

Never had the need to use this, so haven't tried it, but I note the ObjectChoiceField includes a method called:

getWidthOfChoice();

Now I presume that the Width is in pixels, and that the normal process would invoke using the field.font and doing a getAdvance().  But I've often wondered if by changing this I would change the actual width of the Field.

 

Possibly worth a try.  If you do try it, let us know. 

Developer
NitinPatel
Posts: 107
Registered: ‎10-06-2010
My Device: Not Specified

Re: ObjectChoiceField: how to set the width of the dropdown window

Hey Peter,

 

getWidthOfChoice() works!

 

Because it is getting width of only one choice item, I thought it is not for field width and I completely ignored it and spent hours for work around.

 

And just to mention, buy using this, it does not affect the actual width of the Field.

 

Thanks

Nitin

 

 

 

 

Developer
NitinPatel
Posts: 107
Registered: ‎10-06-2010
My Device: Not Specified

Re: ObjectChoiceField: how to set the width of the dropdown window

Oops! here is correction

 

getWidthOfChoice() works fine with Version 4.6 but it is not working on Device software Version 5.0

 

What a nightmare.....

 

 

Nitin

Regular Contributor
RockAlmeida
Posts: 68
Registered: ‎03-15-2011
My Device: 9630

Re: ObjectChoiceField: how to set the width of the dropdown window

You want to make the "button" wider? I find a solution: add spaces to the text you want to show, so it's wider!
Regular Contributor
RockAlmeida
Posts: 68
Registered: ‎03-15-2011
My Device: 9630

Re: ObjectChoiceField: how to set the width of the dropdown window

May be a better way:

override layout(int width, int height):

protected void layout(int width, int height) {

	setMinimalWidth(width - 61); // 61 is the min value, lower than 61 will not work
	super.layout(width, height);
	
}