I have a seemingly simple problem:
I want to create 7 check-boxes (for the days of the week) lined up on 1 line using a
horizontal field manager. Unfortunately a CheckboxField, by default, takes up the whole line. Due to this, CheckboxField SHOULD (and according to the javadoc it does) have a style setting that makes it use only the width it needs. However, my compiler (Eclipse Plug-In) does not recognize “CheckboxField.NO_USE_ALL_WIDTH” and doesn’t compile/package my app.
The CheckboxField declerations:
private CheckboxField cf_sun,
cf_mon,
cf_tue,
cf_wed,
cf_thu,
cf_fri,
cf_sat;
I defined my checkboxes as follows:
cf_sun = new CheckboxField("Sun", false, CheckboxField.NO_USE_ALL_WIDTH); // <-- ERROR
cf_mon = new CheckboxField("Mon", false);
cf_tue = new CheckboxField("Tue", false);
cf_wed = new CheckboxField("Wed", false);
cf_thu = new CheckboxField("Thu", false);
cf_fri = new CheckboxField("Fri", false);
cf_sat = new CheckboxField("Sat", false);
How could I make this work?
According to the BlackBerry Javadocs on CheckboxField:
Are you building your app against the SDK 7.0 libraries? Or something lower? If you use lower than 7.0, then the compiler (rightly) won’t find that new constant.
Anyway, I tried your code on OS 5.0, and
CheckboxFielddid not take up the whole line, if you add them all to aHorizontalFieldManager. But, let’s say that you do need more control over the field width …Luckily, it looks like you have a pretty simple layout. All your fields labels are the same length (3 chars), so you can probably just create a new subclass that sets the width. If you want it to be more dynamic, then you could use
Font.getAdvance()on the checkbox labels to determine exactly how wide each label is, and therefore, exactly how much space each field would need (accounting for the width of the checkbox, too, of course).and then