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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
NitinPatel
Posts: 107
Registered: ‎10-06-2010
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

Please use plain text.
Developer
simon_hain
Posts: 13,830
Registered: ‎07-29-2008
My Carrier: O2 Germany

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
Please use plain text.
Developer
NitinPatel
Posts: 107
Registered: ‎10-06-2010

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

 

Please use plain text.
Developer
peter_strange
Posts: 17,722
Registered: ‎07-14-2008

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. 

Please use plain text.
Developer
NitinPatel
Posts: 107
Registered: ‎10-06-2010

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

 

 

 

 

Please use plain text.
Developer
NitinPatel
Posts: 107
Registered: ‎10-06-2010

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

Please use plain text.
Regular Contributor
RockAlmeida
Posts: 68
Registered: ‎03-15-2011
My Carrier: 3G

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!
Please use plain text.
Regular Contributor
RockAlmeida
Posts: 68
Registered: ‎03-15-2011
My Carrier: 3G

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);
	
}

 

Please use plain text.