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
New Developer
preetiparida
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified

vertcal manager scroll bar

Hi ,

 

  I have a vertical manager with backgroungd image.and all my code i checked in 7100t simulator. but now when i use simulator with small screen i dont get the vertical scrollbar. so how can i achieve a vertical scroll bar. the code is given below . Also i tried adding null field below but it did not helped me.

 

package HelloWorld;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Screen.*;

 

public class HelloWorld extends UiApplication
{
   
    public static void main(String[] args) {
        HelloWorld theApp = new HelloWorld();
         theApp.enterEventDispatcher();
    }
    public HelloWorld() {
      pushScreen(new HelloWorldScreen());
    }

}

   class HelloWorldScreen extends MainScreen {
    //this is the backup button
    private CustomButtonField backUpButton;                   
   //this is the restore button
    private CustomButtonField restoreButton;
    //this is the share button
    private CustomButtonField shareButton;                   
   //this is the import button
    private CustomButtonField importButton;
    //this is the Web button
    private CustomButtonField WebButton;
    //his button is use to backup data from server
    private BigButtonField backup_data_button;
   
    RestoreScreen resscreen;
    WebScreen webscreen;
    //this is the background image
    private Bitmap backgroundBitmap;
    // instance of the backup class
  //  private BackupContacts backupContact;
    //instance of progress bar
    private ProgressBar progressBar;
   
    private int i=0;
   
    int nScreenWidth=0;
    int nScreenHieght=0;
   
   
    VerticalFieldManager vfm;
  
    public HelloWorldScreen()
    {
        super();
       
        //create a label field and add the title to the main screen
        LabelField title = new LabelField("Backup Contacts",Field.FIELD_HCENTER);
        setTitle(title);
       
       
         //create the button here
        backUpButton            = new CustomButtonField("backup");    
        restoreButton           = new CustomButtonField("restore");
        WebButton               = new CustomButtonField("web");
        backup_data_button      = new BigButtonField("backupdata");
       
        //get the screen width and height here  
        nScreenWidth   = Display.getWidth();
        nScreenHieght  = Display.getHeight();  
       
        //display the screen width and height here
        System.out.println("Screen width--->"+nScreenWidth);
        System.out.println("Screen height--->"+nScreenHieght);
       
       
        //set padding according to screen width and height
        backUpButton.setPadding(0,0,0,35);
       
       
        Manager gridFieldManager = new GridFieldManager(3, 0);
       
        //add to grid field manager
        gridFieldManager.add(backUpButton);  
        gridFieldManager.add(restoreButton);
        gridFieldManager.add(WebButton); 
       
       //create the horizontal field manager and add the manager to the status
         HorizontalFieldManager hfm_status = new HorizontalFieldManager();
         hfm_status.add(gridFieldManager);
         setStatus(hfm_status);
          
        //get the background image
        backgroundBitmap = Bitmap.getBitmapResource("bg2.png");
       
        
       
       VerticalFieldManager main_vfm = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.USE_ALL_HEIGHT)
       {
           //Override the paint method to draw the background image.
            public void paint(Graphics graphics)
            {
               //Draw the background image and then call paint.
                graphics.drawBitmap(0, 0, 240,240, backgroundBitmap, 0, 0);
                super.paint(graphics);
            }
                    
          };
         
         
       
         //add the background image here
         add(main_vfm);
        
         
         backup_data_button.setPadding(140,0,0,30);
        
                        
        //add the backup button to the main_vfm which user will click
         main_vfm.add(backup_data_button); 
        
               
       //fire event for going to backup screen.
         backUpButton.setChangeListener(new FieldChangeListener()
         {
            public void fieldChanged(Field field, int context)
             {  
                Dialog.alert("You are in Backup Screen.");
             }
            
            
       });
      
       //fire event for backing up data from server
         backup_data_button.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int context)
             {  
              //Dialog.alert("Backup button clicked!");
               //backupContact = new BackupContacts();
               progressBar   = new ProgressBar("Backing up...Please Wait",100,600); 
               progressBar.start();
             }
       });
      
           
          // fire event for navigating to restore Screen.
          restoreButton.setChangeListener(new FieldChangeListener()
            {
                public void fieldChanged(Field field, int context) {  
                //Dialog.alert("Restore button clicked for screen navigation!");
                //System.out.println("now call restore");
                resscreen = new RestoreScreen();
                UiApplication.getUiApplication().pushScreen(resscreen);
            }
        });
       
         // fire event for navigating to web Screen.
          WebButton.setChangeListener(new FieldChangeListener()
            {
                public void fieldChanged(Field field, int context) {  
               
                //Dialog.alert("Web button clicked for screen navigation!");
               
                webscreen = new WebScreen();
                UiApplication.getUiApplication().pushScreen(webscreen);
               
            }
        });
    }
      
      
      
      
        //on close or on escape this function gets called   
        public boolean onClose()
         {
            Dialog.alert("Thank u For Using IDRIVELITE");
            System.exit(0);
            return true;
         }
        
        
}

 

thanks&regards

 

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: vertcal manager scroll bar

Have you tried setting Manager.VERTICAL_SCROLL for your VerticleFieldManager.

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
New Developer
preetiparida
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified

Re: vertcal manager scroll bar

Hi,

 

 

  yes i tried but it does not make any difference.

 

Thanks&Regards

Please use plain text.
New Developer
preetiparida
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified

Re: vertcal manager scroll bar

Hi all, i think no body is going to help me out for my issue.can anybody guide me how to add a NullField to my Vertical managerField. i tried adding a nullfield to my vertical manager field to which allows the vertical scroll but when i scroll down there is big white portion visible between the status bar and the background image of my vertical manager. what to remove this white portion. Thanks&Regards
Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: vertcal manager scroll bar

Give a look at this KB article, It had added a Null Field.

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800508/...


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
New Developer
preetiparida
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified

Re: vertcal manager scroll bar

Hi BBdeveloper,

 

        thanks for the reply but i have done the same the way it is mention in the link but the image which is painted in the vertical manager

      

         doesnot fit to the screen and a blank space is visible at the bottom of the screen.i think the button is not added to the    verticalmanager. what can be the solution for this.

 

thanks&regards

Please use plain text.
Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: vertcal manager scroll bar

[ Edited ]

Hi,

 

I think you should try overriding subLayout() method of verticalfieldmanager.

 

Divide your screen into different managers and add component in different managers.

 

Reason you are seeing white portion is that you are adding image in your manager and when you manager moves your image also moves.

 

Override keyDown() of  your verticalfieldmanager and call invalidate in it.

 

here is the link which will help you.

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=30432#M30432

Message Edited by Rajat_10Sep on 04-24-2009 08:45 AM
Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: vertcal manager scroll bar

Give a look at this KB article. Which talks about Scrollable Image Field creation.

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.