Arrange UI components
To arrange components on a screen, use BlackBerry® API layout managers.
The following four classes extend the
Manager
class to provide predefined layout managers:
•
VerticalFieldManager
•
HorizontalFieldManager
•
FlowFieldManager
•
DialogFieldManager
1.
Import the following classes:
•
net.rim.device.api.ui.Manager
•
net.rim.device.api.ui.container.VerticalFieldManager
•
net.rim.device.api.ui.container.HorizontalFieldManager
•
net.rim.device.api.ui.container.FlowFieldManager
•
net.rim.device.api.ui.container.DialogFieldManager
2.
To create a custom layout manager, extend
Manager
.
Create a layout manager
1.
Import the following classes:
•
net.rim.device.api.ui.Screen
•
net.rim.device.api.ui.Manager
•
net.rim.device.api.ui.container.VerticalFieldManager
•
net.rim.device.api.ui.component.BitmapField
•
net.rim.device.api.ui.container.HorizontalFieldManager
•
net.rim.device.api.ui.container.FlowFieldManager
•
net.rim.device.api.ui.container.DialogFieldManager
•
net.rim.device.api.ui.container.MainScreen
2.
Create an instance of the appropriate
Manager
subclass.
3.
Add UI components to the layout manager.
4.
Add the layout manager to the screen. In the following code sample, we create a
VerticalFieldManager
to organize
fields from top to bottom in a single column. We then add several
BitmapField
s to the
VerticalFieldManager
. We invoke
MainScreen.add()
to add the
VerticalFieldManager
to the
MainScreen
of the application.
VerticalFieldManager vfm = new VerticalFieldManager
(Manager.VERTICAL_SCROLL);
vfm.add(bitmapField);
Development Guide
Arrange UI components
29