04-28-2012 08:20 PM
Hi,
I'm trying to add a LabelField - GaugeField - LabelField inside a HorizontalFieldManager.
The both labels are being added this i can confirm by the width occupied by the gauge.
But i cannot see the second label. it is as if it disappeared.
HorizontalFieldManager hfm = new HorizontalFieldManager();
LabelField lf1 = new LabelField("hi");
GaugeField gf = new GaugeField("" , 1 , 100 , 30 , GaugeField.NO_TEXT);
LabelField lf2 = new LabelField("bye");
hfm.add(lf1);
hfm.add(gf);
hfm.add(lf2);
add(hfm);
so i tried adding gaugeField into another HorizontalFieldManager and then add it like this.
HorizontalFieldManager hfm = new HorizontalFieldManager();
HorizontalFieldManager hfm2 = new HorizontalFieldManager();
LabelField lf1 = new LabelField("hi");
GaugeField gf = new GaugeField("" , 1 , 100 , 30 , GaugeField.NO_TEXT);
LabelField lf2 = new LabelField("bye");
hfm2.add(gf);
hfm.add(lf1);
hfm.add(hfm2);
hfm.add(lf2);
add(hfm);
but even this didnt helped. The second label is still invisible ![]()
Can anyone help me here?
i'm using
Blackberry 9530-Verizon
OS version : 5.0.0.328
Thanks ![]()
Solved! Go to Solution.
04-28-2012 09:27 PM
I got the answer ![]()
Instead of creating second hosidontalFieldManager in the begining
i created it after i created objects of lf1 and lf2.
now i set the width of this hfm2 to
getPreferredWidth() - timeStart.getPreferredWidth() - timeEnd.getPreferredWidth() ,getPreferredHeight()
This will substract the width occupied by label from total width and set the gauge width to that remaining space.
HorizontalFieldManager hfm = new HorizontalFieldManager();
LabelField lf1 = new LabelField("hi");
GaugeField gf = new GaugeField("" , 1 , 100 , 30 , GaugeField.NO_TEXT);
LabelField lf2 = new LabelField("bye");
HorizontalFieldManager hfm2 = new HorizontalFieldManager(){
public void sublayout(int maxWidth, int maxHeight) {
super.sublayout(getPreferredWidth() - lf1.getPreferredWidth() - lf2.getPreferredWidth() ,getPreferredHeight());
setExtent(getPreferredWidth() - lf1.getPreferredWidth() - lf2.getPreferredWidth() , getPreferredHeight());
}
};
hfm2.add(gf);
hfm.add(lf1);
hfm.add(hfm2);
hfm.add(lf2);
add(hfm);
04-28-2012 09:29 PM
although i didnt understood why i have to do that.
since i'm using field manager the gauge width should be set automatically
but it seems like that gauge is occuping Display.getWidth() (whole screen).
can anyone explain why it is like that???