Multiple buttons with same width equal to widest button
I have multiple ButtonFields in a VerticalFieldManager. By d开发者_开发问答efault the width of each button depends on the text it contains.
I would like all the buttons to be of the same width - equal to the width of the widest button.
Take a look at the BlackBerry Developers Knowledge Base:
How to - Implement advanced buttons, fields, and managers
Last Updated: 12 February 2010
Article Number: DB-00796
You are probably looking for the VerticalButtonFieldSet!
Step 1 - Extend the VerticalFieldManager class, and make the constructor take in a bunch of Strings that you want to put end each button.
Step 2 - Find the longest of String out of the Strings passed into the manager.
Step 3 - create the button for the longest string
Step 4 - create all other buttons, and set their width to the same as the 1st (see setExtent)
Step 5 - add the buttons to the manager in the order you want them to appear
FIN
Have you tried using the Field.USE_ALL_WIDTH
style flag?
Try ButtonField buttonField = new ButtonField("ButtonText", Field.USE_ALL_WIDTH);
and that should use the full width.
If that doesn't work, try extending ButtonField, overriding layout and calling setExtent(width, height)
with the width and height that you want.
精彩评论