01-19-2011 02:17 AM
Hello Friends,
here i am showing one backgroud image. and some labelfilds. evrythig is working. but if i add 10 elements in screen than it show but not scrolling. see my code. what should i do for that??
i want my page scrollable. but it will not work. just tell me what should i do for that??
public class ANULOMA_VILOMA extends MainScreen
{
private VerticalFieldManager mainManager;
private VerticalFieldManager subManager;
private Bitmap _backgroundBitmap = Bitmap.getBitmapResource("IMG/menu_bg.png");
private int deviceWidth = Display.getWidth();
private int deviceHeight = Display.getHeight();
private LabelField lbl=new LabelField();
HorizontalFieldManager hfm = new HorizontalFieldManager(Field.FIELD_HCENTER | Field.FIELD_VCENTER);
HorizontalFieldManager rowHolder = new HorizontalFieldManager(NO_HORIZONTAL_SCROLL |
HorizontalFieldManager.FIELD_HCENTER);
HorizontalFieldManager topHolder = new HorizontalFieldManager(NO_HORIZONTAL_SCROLL |
HorizontalFieldManager.FIELD_HCENTER | HorizontalFieldManager.FIELD_VCENTER);
//CustomLabel lblheader=new CustomLabel("About",DrawStyle.HCENTER|DrawStyle.VC ENTER,Display.getWidth(),(int)(Display.getHeight() /10),Color.RED,46760,16580529);
HorizontalFieldManager hfm_holder = new HorizontalFieldManager(NO_HORIZONTAL_SCROLL |
HorizontalFieldManager.FIELD_HCENTER | HorizontalFieldManager.FIELD_VCENTER);
VerticalFieldManager vfm12=new VerticalFieldManager(VERTICAL_SCROLL| VERTICAL_SCROLLBAR);
LabelField lbl1,lbl2,lbl3,lbl4,lbl5,lbl6;
ANULOMA_VILOMA()
{
lbl1=new LabelField("Step 1: Sit comfortably with back straight and hands resting on your knees.");
lbl2=new LabelField("step2: Bend the forefinger and middle finger of your right hand.");
lbl3=new LabelField("step3: place the thumb on the right nostril and press the ring finger on the left nostril.Breathe in through the right nostril closing the left.");
lbl4=new LabelField("step4: hold breath closing both nostrils.");
lbl5=new LabelField("step 5:Place the ring finger on the left nostril and press the right nostril with the thumb. Exhale through the left nostril.");
lbl6=new LabelField("step 6: Reverse the position of the fingers as in setp 3.");
topHolder.add(lbl);
try
{
int leftEmptySpace = (Display.getWidth()-hfm.getPreferredWidth())/3;
int topEmptySpace = (Display.getHeight()-hfm.getPreferredHeight())/3;
Bitmap header=Bitmap.getBitmapResource("IMG/header1.png") ;
header =Utilities.myScale(EncodedImage.getEncodedImageRes ource("IMG/header1.png"),(int) Display.getWidth()/2,(int)Display.getHeight()/8).g etBitmap();
BitmapField hd=new BitmapField(header);
//Bitmap backimg=Bitmap.getBitmapResource("IMG/menu_bg.png" );
//backimg =Utilities.myScale(EncodedImage.getEncodedImageRes ource("IMG/menu_bg.png"), Display.getWidth()/3, Display.getHeight()/3).getBitmap();
//BitmapField bf=new BitmapField(backimg);
mainManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR)
{
public void paint(Graphics graphics)
{
graphics.clear();
graphics.drawBitmap(0, 0,deviceWidth,deviceHeight,_backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
//this manger is used for adding the componentes
subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR )
{
protected void sublayout( int maxWidth, int maxHeight )
{
int displayWidth = deviceWidth;
int displayHeight = deviceHeight;
super.sublayout( displayWidth, displayHeight);
setExtent( displayWidth, displayHeight);
}
};
topHolder.add(hd);
hd.setMargin(0, 0, 10, 10);
vfm12.add(lbl1);
lbl1.setMargin(0, 0, 10, 10);
vfm12.add(lbl2);
lbl2.setMargin(0, 0, 10, 10);
vfm12.add(lbl3);
lbl3.setMargin(0, 0, 10, 10);
vfm12.add(lbl4);
lbl4.setMargin(0, 0, 10, 10);
vfm12.add(lbl5);
lbl5.setMargin(0, 0,10, 10);
vfm12.add(lbl6);
FontFamily alphaSerifFamily = null;
try
{
alphaSerifFamily = FontFamily.forName("bbalpha serif");
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
Font appFont1= alphaSerifFamily.getFont(Font.PLAIN, 6, Ui.UNITS_pt);
lbl1.setFont(appFont1);
lbl2.setFont(appFont1);
lbl3.setFont(appFont1);
lbl4.setFont(appFont1);
lbl5.setFont(appFont1);
subManager.add(topHolder);
subManager.add(vfm12);
////////////////////////////////////////////////// /
//add subManager over the mainManager
mainManager.add(subManager);
//finally add the mainManager over the screen
this.add(mainManager);
}
catch(Exception ex)
{
Dialog.alert("Exception"+ex);
}
}
}
thanks and regards.
ajay patil.
01-19-2011 02:24 AM
in mainManager you have given the
Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR
so its not scrolling.
Note: i think ClassName should be in CamelCase.
01-19-2011 02:45 AM
thanks for reply
i remove that line but still that not scrolling. what is wrong in my code??
01-19-2011 06:12 AM - edited 01-19-2011 06:13 AM
No that's the contrary you have to do. Follow this:
- Reset what you wrote: Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR in your MainManager
- And remove Scrollable from your subManager to have this:
subManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL)
That should work