Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
patilajayr
Posts: 404
Registered: ‎07-28-2010
My Carrier: hi

Background image with scrollable.

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.VCENTER,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.getEncodedImageResource("IMG/header1.png"),(int) Display.getWidth()/2,(int)Display.getHeight()/8).getBitmap();
			BitmapField hd=new BitmapField(header);
			//Bitmap backimg=Bitmap.getBitmapResource("IMG/menu_bg.png");
			//backimg =Utilities.myScale(EncodedImage.getEncodedImageResource("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.

Please use plain text.
Developer
vivart
Posts: 147
Registered: ‎08-27-2010
My Carrier: airtel

Re: Background image with scrollable.

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.

Please use plain text.
Developer
patilajayr
Posts: 404
Registered: ‎07-28-2010
My Carrier: hi

Re: Background image with scrollable.

thanks for reply

                    i remove that line but still that not scrolling. what is wrong in my code??

 

 

Please use plain text.
Developer
Hithredin
Posts: 400
Registered: ‎06-03-2010
My Carrier: Free

Re: Background image with scrollable.

[ Edited ]

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

 

Please use plain text.