Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Editfield scroll fails to reach top in blackberry
- et=new EditField("Email-id:","");
- pwd=new PasswordEditField("Password:","");
- ab.add(et,35,110);
- ab.add(pwd,35,150);
- et=new EditField("Email-id:","");
- pwd=new PasswordEditField("Password:","") {
- protected int moveFocus(int amount, int status, int time) {
- int cursorPosition = this.getCursorPosition();
- if ((cursorPosition == 0) && (amount < 0)) {
- et.setFocus();
- return 0;
- }
- else {
- return super.moveFocus(amount, status, time);
- }
- }
- };
- et=new EditField("Email-id:","");
- pwd=new PasswordEditField("Password:","");
- HorizontalFieldManager manager = new HorizontalFieldManager();
- manager.add(et);
- manager.add(pwd);
- ab.add(manager, yourX, yourY);
- public class loginscreen extends MainScreen implements FieldChangeListener {
- private int deviceWidth = Display.getWidth();
- private int deviceHeight = Display.getHeight();
- private VerticalFieldManager subManager;
- private VerticalFieldManager mainManager;
- public long mycolor = 0x00FFFFFF;
- Screen _screen = home.Screen;
- TextField heading = new TextField(Field.NON_FOCUSABLE);
- TextField username_ef = new TextField();
- PasswordEditField password_ef = new PasswordEditField();
- CheckboxField rememberpass = new CheckboxField();
- public ButtonField login_bt = new ButtonField("Login", ButtonField.CONSUME_CLICK);
- public ButtonField register_bt = new ButtonField("Register", ButtonField.CONSUME_CLICK);
- public loginscreen()
- {
- super();
- final Bitmap backgroundBitmap = Bitmap.getBitmapResource("bgd.png");
- HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR )
- {
- protected void sublayout(int width, int height)
- {
- Field field;
- int numberOfFields = getFieldCount();
- int x = 245;
- int y = 0;
- for (int i = 0;i < numberOfFields;i++)
- {
- field = getField(i);
- setPositionChild(field,x,y);
- layoutChild(field, width, height);
- x +=_screen.getWidth()-381;
- y += 0;//l17
- }
- width=_screen.getWidth();
- height=48;//w19
- setExtent(width, height);
- }
- };
- 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);
- }
- public void paint(Graphics graphics)
- {
- graphics.setColor((int) mycolor);
- super.paint(graphics);
- }
- };
- username_ef.setLabel("Username: ");
- password_ef.setLabel("Password: ");
- rememberpass.setLabel("Remember Password");
- heading.setLabel("Please enter your credentials: ");
- username_ef.setMaxSize(8);
- password_ef.setMaxSize(20);
- subManager.add(heading);
- subManager.add(username_ef);
- subManager.add(password_ef);
- subManager.add(rememberpass);
- subManager.add(new SeparatorField());
- login_bt.setChangeListener(this);
- register_bt.setChangeListener(this);
- hfm.add(login_bt);
- hfm.add(register_bt);
- subManager.add(hfm);
- mainManager.add(subManager);
- this.add(mainManager);
- }
- public boolean onSavePrompt()
- {
- return true;
- }
- public void fieldChanged(Field field, int context) {
- // TODO Auto-generated method stub
- if(field == login_bt)
- {
- //do your code for login button click
- }
- if(field == register_bt)
- {
- //code for register button click
- }
- }}
- // inside MainScreen constructor
- add(new EditField("Username:","",0));
- add(new EditField("Password:","",0));
- add(new ButtonField(buttonBMP,ButtonField.CONSUME_CLICK));
Add Comment
Please, Sign In to add comment