vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL);
vfm.add(new LabelField("horizontally centered...",Field.FIELD_HCENTER | LabelField.FOCUSABLE));
vfm.add(new LabelField("horizontally centered...",Field.FIELD_HCENTER | LabelField.USE_ALL_WIDTH | LabelField.FOCUSABLE));
add(vfm);
Why can't I get my fields to be horizontally aligned. I have tried different combinations but can't get a single labelfield to be centered. If I add a second field below with USE_ALL_WIDTH then the first field gets centered.
I don't know what the proper way of doing it!
EDIT:
Following the link provided below, I tried doing:
vfm = new VerticalFieldManager(Field.USE_ALL_WIDTH | Field.USE_ALL_HEIGHT){
protected void sublayout( int width, int height ) {
super.sublayout( width, height );
width = getWidth();
height = getHeight();
for (int i = 0;i < this.getFieldCount() - 1; i++)
{
System.out.println("field:" + i);
Field field = this.getField(i);
//this positions the item in the middle of the manager
int x = (int)((width - field.getWidth()) * 0.50);
setPositionChild(field, x, field.getTop());
}
}
};
vfm.add(new LabelField("Facebook"));
add(vfm);
The problem is that I'm not getting any fields. How am I supposed to implement it?