I want to add a TextField and a ButtonField to a HorizontalFieldManager. Now, I am using the following code
HorizontalFieldManager hfmFieldManager = new HorizontalFieldManager(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL | USE_ALL_WIDTH);
hfmFieldManager.setPadding(5, 0, 5, 0);
VerticalFieldManager buttonFieldManager = new VerticalFieldManager(USE_ALL_WIDTH | Field.FIELD_RIGHT);
ButtonField btnDone = new ButtonField("DONE", FIELD_VCENTER | Field.FIELD_RIGHT);
btnDone.setMargin(0, MARGIN, 0, MARGIN);
buttonFieldManager.add(btnDone);
TextField txtField = new TextField(FIELD_VCENTER | FIELD_LEFT)/*{
protected void layout(int width, int height) {
super.layout((int) (Display.getWidth() * 0.5) , getPreferredHeight());
}
}*/;
txtField.setBorder(roundedBorder);
txtField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
hfmFieldManager.add(txtField);
hfmFieldManager.add(buttonFieldManager);
But it shows TextField Only. I want to show buttonfield completely at the right side and the remaining left side for textField.(Show TextField,Buttonfield from left to right).
How can i adjust the width of textfield which is compatible for all screen sizes?
Thanks in Advance
Try this -
then add the field to your screen.
//JustifiedHorizontalFieldManager class is given below