03-07-2011 04:15 PM
I've tripple checked this layout and I dont see why there is a problem.. When I want to have 2 edit fields side by side using two vertical field managers in one horizontal, the 2nd vertical field manager doesn't show up at all. In the end, editfield0 should be on the left and editfield1 directly beside on the right
HorizontalFieldManager hfm1 = new HorizontalFieldManager();
VerticalFieldManager vfm1 = new VerticalFieldManager();
VerticalFieldManager vfm2 = new VerticalFieldManager();
vfm1.add(Label0);
vfm1.add(EditField0);
vfm1.add(Profile); //Radio buttons
vfm1.add(Profile1);
vfm1.add(Profile2);
vfm1.add(Profile3);
vfm1.add(Profile4);
vfm1.add(Profile5);
vfm2.add(Label1);
vfm2.add(EditField1);
vfm2.add(Label2);
vfm2.add(EditField2);
hfm1.add(vfm1);
hfm1.add(vfm2);
add(hfm1);If I comment out editfield0 the whole thing works, if I comment out editfield1 its still messed up
Solved! Go to Solution.
03-07-2011 04:26 PM
There is a hidden feature of EditField - it is "width hungry". Any EditField, no matter how many maxChars it has, always behaves as though USE_ALL_WIDTH were in effect. This makes vfm1 occupy all given width as well, not leaving any room for vmf2.
In order to curb the field's appetite, define your edit field like this:
EditField editField0 = new EditField(...) {
protected void layout(int width, int height) {
// calculate (or precalculate elsewhere) the desired width
int myMaxWidth = <...>;
// use it!
super.layout(Math.min(width, myMaxWidth), height);
}
};
Good luck!
03-07-2011 08:36 PM
When I am testing on the emulator for the bold 9700 it works fine, and I move it on to my bold 9780 and its the same as before, the 2nd vertical manager on the right is missing.
Would this be caused because I am emulating OS5 but testing on OS6? If so, what is the fix for OS6 devices?
03-07-2011 08:56 PM
And thats not even with having 2 editfields side by side but rather
EDITFIELD
RADIO ------- EDITFIELD
RADIO ------- EDITFIELD
RADIO -------BUTTON BUTTON
RADIO
03-08-2011 09:46 AM
After researching this a little bit more, I found that RadioButton is quite inconsistent - on some platforms it, too, takes the whole width. So you might need the same exercise with your RadioButtonFields. Try it and see if it works.
03-08-2011 02:00 PM
I find that very dumb, all I want it to do is take up as much of the screen as it needs and no more. So when I move the app from device to device with different screen sizes there aren't any layout issues.
03-08-2011 02:31 PM
You are not alone - there are many small and not so small inconsistencies between different BlackBerry models and OS versions.
As for your initial problem - since you cannot rely on either EditField or RadioButtonField to "behave", add them normally to your managers, but create your managers differently:
HorizontalFieldManager hfm1 = new HorizontalFieldManager();
VerticalFieldManager vfm1 = new VerticalFieldManager() {
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(maxWidth / 2, maxHeight);
}
};
VerticalFieldManager vfm2 = new VerticalFieldManager();
This way your left side manager is guaranteed to take only half of the screen, leaving enough room on the right.
So drop your layout overrides from the fields and "squeeze" the whole Manager ![]()
03-08-2011 03:30 PM
Thanks, that is a very good solution!