I am trying to figure out my first screen for Blackberry with JDE4.2.1.
The layout I am trying to create is as follows:
---------------------------------
! Header img!
! -------------------------------!
! I! Title!
! M! --------------------------!
! G! Body Txt!
! ! !
! ! Button1 Button2!
! ! --------------------------!
! ! Footer text!
---------------------------------
So far, I have managed to achieve this layout with a combination of Horizontal and VerticalFieldLayout, and the code looks like this:
class MyScreen extends MainScreen {
RadioButtonGroup _optionGroup = new RadioButtonGroup();
Manager _sideBarHzMgr = new HorizontalFieldManager();
Manager _bodyContentMgr = new VerticalFieldManager();
public MyScreen(String label) {
super();
doHeader(label);
doBody();
doFooter();
}
void doHeader(String label) {
setTitle(new LabelField("Application v1.0.1", LabelField.ELLIPSIS));
Bitmap headerImg = Bitmap.getBitmapResource("header1.jpg");
headerImg = cropBitmap(headerImg, Display.getWidth(), headerImg.getHeight());
add(new BitmapField(headerImg));
Bitmap sidebar = Bitmap.getBitmapResource("sidebar.jpg");
sidebar = cropBitmap(sidebar, sidebar.getWidth(), Display.getHeight());
BitmapField bf = new BitmapField(sidebar, BitmapField.NON_FOCUSABLE);
_sideBarHzMgr.add(bf);
RichTextField rtf = new RichTextField(label, new int[] { 0, label.length() }, new byte[] { 0 },
new Font[] { Font.getDefault().derive(Font.BOLD) }, RichTextField.TEXT_ALIGN_HCENTER
| RichTextField.NON_FOCUSABLE);
_bodyContentMgr.add(rtf);
}
void doBody() {
RadioButtonField rbField1 = new RadioButtonField("Option1", _optionGroup, true,
RadioButtonField.FIELD_LEFT);
RadioButtonField rbField2 = new RadioButtonField("Option2", _optionGroup, false,
RadioButtonField.FIELD_LEFT);
super._bodyContentMgr.add(rbField1);
super._bodyContentMgr.add(rbField2);
HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.FIELD_LEFT);
hfm.add(_closeButton);
hfm.add(_contButton);
super._bodyContentMgr.add(hfm);
}
void doFooter() {
_bodyContentMgr.add(new LabelField());
_bodyContentMgr.add(new SeparatorField());
_bodyContentMgr.add(new RichTextField("©MyCo footer 2010.", RichTextField.TEXT_ALIGN_HCENTER
| RichTextField.NON_FOCUSABLE | RichTextField.FIELD_BOTTOM));
_sideBarHzMgr.add(_bodyContentMgr);
add(_sideBarHzMgr);
}
}
, VerticalLayoutManager (bodyContentMgr) , . Nevermind .
, - .
bodyContentMgr ?
:
---------------------------------
! Header img !
!-------------------------------!
! I ! Title !
! M !-----------------------------------------------!
! G ! Body Txt !
! ! !
! ! Button1 Button2 !
! !-----------------------------------------------!
! ! Footer text !
--------------------------------!