Hi everybody,now I have some questions with using Buttonfield and ObjectChioceField.
In my program,I have one ButtonFiled and two ObjectChoiceField. I would like they are arranged in a row,but the width of the screen is not enough show them all.
Following is my key code
Code:
final class CameraScreen extends MainScreen
{
private AutoWidthButtonField _photoButton;
private sObjectChoiceField enChioceField;
private sObjectChoiceField zoomChoiceField;
......
......
public void createUI()
{
...
_photoButton = new AutoWidthButtonField( "Take" );
enChoiceField = new sObjectChoiceField(null, _encodings, 0);
zoomChoiceField = new sObjectChoiceField(null, zoom, 0);
FlowFieldManager hfm = new FlowFieldManager(net.rim.device.api.ui.Manager.FIELD_HCENTER);
hfm.add(_photoButton);
hfm.add(_encodingField);
hfm.add(zoomField);
add(hfm);
}
}
final class AutoWidthButtonField extends ButtonField
{
AutoWidthButtonField(String label) { super(label); }
public int getPreferredWidth()
{
int width = (Display.getWidth() / 10);
return width;
}
/*
protected void layout(int width, int height)
{
super.layout(width, height);
setExtent(getPreferredWidth(), getPreferredHeight());
}
*/
}
final class sObjectChoiceField extends ObjectChoiceField
{
sObjectChoiceField(String label, Object[] choices, int initialIndex) { super(label,choices,initialIndex); }
public int getPreferredWidth()
{
int width = (Display.getWidth() / 10);
return width;
}
/*
protected void layout(int width, int height)
{
super.layout(width, height);
setExtent(getPreferredWidth(), getPreferredHeight());
}
*/
} The result is the width of the button field has been resize,but the label can not be showed.
But it is not work to the ObjectChoiceField.
So my questions are how to resize the width of the buttons,and how to resize the Font size to suit the field.