-
Notifications
You must be signed in to change notification settings - Fork 1
v08 002 01 basic elements
The GridLayout will give you the possibility to place elements in a more or less free way on the screen. For this divide your screen in rows and cols.
Use the following method to create buttons. As first example we will put a button in every defined place inside the Gridlayout.
How to do this? First we define a GridLayout with the dimension 4x4.
final GridLayout grid4X4 = new GridLayout(4, 4);
As next we define a helper method to create a button.
private Button btn(String caption){
Button button = new Button(caption);
button.setSizeFull();
return button;
}
Now we will start filling up the Layout. As you can see, the place will be addressed with the coordinates itself. For example ButtonCA will be at place (2,0)
grid4X4.addComponent(btn("AA"), 0,0);
grid4X4.addComponent(btn("BA"), 1,0);
grid4X4.addComponent(btn("CA"), 2,0);
grid4X4.addComponent(btn("DA"), 3,0);
grid4X4.addComponent(btn("AB"), 0,1);
grid4X4.addComponent(btn("BB"), 1,1);
grid4X4.addComponent(btn("CB"), 2,1);
grid4X4.addComponent(btn("DB"), 3,1);
Now it is your turn, to create the following versions out of it. Remember, to use more as one place for an element inside the Layout, define the start and stop coordinates.
for feedback or questions :
- Twitter : @SvenRuppert
- email: sven.ruppert (a) gmail.com