04-24-2009 02:25 AM
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_
{
//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(resscr
}
});
// 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(webscr
}
});
}
//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®ards
04-24-2009 02:38 AM
04-24-2009 02:50 AM
Hi,
yes i tried but it does not make any difference.
Thanks&Regards
04-24-2009 06:14 AM
04-24-2009 06:19 AM
Give a look at this KB article, It had added a Null Field.
04-24-2009 07:59 AM
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®ards
04-24-2009 08:43 AM - edited 04-24-2009 08:45 AM
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/mess
04-24-2009 09:37 AM
Give a look at this KB article. Which talks about Scrollable Image Field creation.