10-14-2012 08:37 AM
i have 3 field
first is button i want to put at left
second is label i want to put at center
third is button i want to put at right
all 3 field at one single line
please anybody help me
Solved! Go to Solution.
10-14-2012 06:57 PM
It sure is nasty, but this is the only way to do it without having to install an external class:
// Left aligned vfm to hold the button VerticalFieldManager left = new VerticalFieldManager(Manager.FIELD_LEFT); ButtonField leftbutton = new ButtonField("left"); left.add(leftbutton); // Centre aligned vfm to hold the label VerticalFieldManager centre = new VerticalFieldManager(Manager.FIELD_HCENTER); LabelField centrelabel = new LabelField("Centre"); centre.add(centrelabel); // Right aligned vfm to hold the button VerticalFieldManager right = new VerticalFieldManager(Manager.FIELD_RIGHT); ButtonField rightbutton = new ButtonField("right"); right.add(rightbutton); // Create a 3x1 evenly spaced grid to hold the above vfms GridFieldManager gridFieldManager = new GridFieldManager(1,3, Manager.USE_ALL_WIDTH); gridFieldManager.setColumnProperty(0, GridFieldManager.AUTO_SIZE, 0); gridFieldManager.setColumnProperty(1, GridFieldManager.AUTO_SIZE, 0); gridFieldManager.setColumnProperty(2, GridFieldManager.AUTO_SIZE, 0); gridFieldManager.setRowProperty(0, GridFieldManager.AUTO_SIZE, 0); // Add the left vfm to the grid VerticalFieldManager vfmLeft = new VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT ); vfmLeft.add(left); gridFieldManager.add(vfmLeft); // Add the centre vfm to the grid VerticalFieldManager vfmCentre = new VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT ); vfmCentre.add(centre); gridFieldManager.add(vfmCentre); // Add the right vfm to the grid VerticalFieldManager vfmRight = new VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT ); vfmRight.add(right); gridFieldManager.add(vfmRight); add(gridFieldManager);
10-14-2012 08:11 PM
When I compile that snippet and run it on the Bold 9900 simulator, all three items are on a single line and aligned as you wanted.
What version are you running?
10-14-2012 08:26 PM
Okay, I know what you mean.
The reason why that is there is because we assigned our vertical field managers to use all the height of the display. If you want to add another field to the display, you will need to modify the grid that we created and insert the field into the correct space.
I can help you do that if you provide some more information as to where you want it.