Multiple buttons with same width equal to widest b

2019-03-31 22:41发布

I have multiple ButtonFields in a VerticalFieldManager. By default 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.

标签: blackberry
3条回答
趁早两清
2楼-- · 2019-03-31 22:50

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!

查看更多
爷、活的狠高调
3楼-- · 2019-03-31 22:55

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

查看更多
地球回转人心会变
4楼-- · 2019-03-31 22:59

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.

查看更多
登录 后发表回答