I would like to layout two buttons side by side and have multiple rows of these buttons like so -
B1 B2
B1 B2
B1 B2
开发者_高级运维
For this do I need to combine VerticalFieldManager and HorizontalFieldManager somehow ?
Thanks
If you're using JDK 5.0 or greater, there's GridFieldManager. If you're using anything below 5.0, you'll have to use nested Vertical/Horizontal field managers.
Here is a TableLayoutManager
class to support such type of layouts.
TableLayoutManager.java
You can download and copy it in your porject and use it.
Use TableLayoutManager
like this.
TableLayoutManager btnManager= new TableLayoutManager(new int[ {TableLayoutManager.USE_PREFERRED_SIZE, TableLayoutManager.USE_PREFERRED_SIZE},Manager.FIELD_HCENTER);
btnManager.add(B1);
btnManager.add(B2);
btnManager.add(B1);
btnManager.add(B2);
you can even define your number of columns and there layout styles.
精彩评论