I want to create an editfield whose cursor keeps at righthandside of it.
To illustrate if i want to write "blackberry", result should be like this.
<-----------width-of-editfield------>
b
bl
bla
blac
black
blackb
blackbe
blackber
blackberr
blackberry
Thanks
Because of non-sense of lack of reputation thing, i can not answer my own question.
Any way, I found an easy way. width refers to width of the manager which holds this edit field.
editField = new EditField("","",maxChars,EditField.NO_NEWLINE | EditField.NON_SPELLCHECKABLE){
protected boolean keyChar(char key, int status, int time) {
editField.setPadding(0, 0, 0, width - (getFont().getAdvance(this.getText())) - 10);
invalidate();
return super.keyChar(key, status, time);
}
};
You will have to create your own Manager, unfortunately. There is no simple or obvious way to do this.
A solution with source code was posted on the BlackBerry forums.
Just like Swati's solution. I did like this:
editField = new EditField("", "", maxChars, EditField.NO_NEWLINE | EditField.NON_SPELLCHECKABLE){
protected boolean keyChar(char key, int status, int time){
switch (key){
case Characters.BACKSPACE:{
try {
text = text.substring(0,text.length()-1);
invalidate();
} catch (IndexOutOfBoundsException e) {}
return true;
}
}
text = text + key;
invalidate();
return true;
}
protected void paint(Graphics graphics) {
graphics.drawText(text,0, 0, DrawStyle.RIGHT, width - 10);
super.paint(graphics);
}
};
Related
I want to manually display a field.
public class Main_NewsDetail extends MainScreen {
private Custom_FontField slider;
private boolean a;
public Main_NewsDetail() {
super(USE_ALL_WIDTH);
slider = new Custom_FontField(
Bitmap.getBitmapResource("slider_thumb_normal.png"),
Bitmap.getBitmapResource("slider_progress_normal.png"),
Bitmap.getBitmapResource("slider_base_normal.png"),
Bitmap.getBitmapResource("slider_thumb_focused.png"),
Bitmap.getBitmapResource("slider_progress_focused.png"),
Bitmap.getBitmapResource("slider_base_focused.png"),
Bitmap.getBitmapResource("slider_thumb_pressed.png"),
Bitmap.getBitmapResource("slider_progress_pressed.png"),
Bitmap.getBitmapResource("slider_base_pressed.png"), 35, 10, 5,
5, FOCUSABLE);
if(a)
add(slider);
}
public class Custom_NewsDetailBottom extends Manager implements
FieldChangeListener {
Custom_NewsDetailBottom() {
super(Manager.USE_ALL_WIDTH | Manager.NO_VERTICAL_SCROLL
| Manager.NO_HORIZONTAL_SCROLL);
Background background = BackgroundFactory
.createBitmapBackground(bg);
setBackground(background);
fontbtn = new Custom_ButtonField(font, fontactive, fontactive) {
protected boolean navigationClick(int status, int time) {
a = !a; <-- here is to control field display
return true;
}
};
fontbtn.setChangeListener(this);
add(fontbtn);
}
protected void sublayout(int width, int height) {
Field field = getField(0);
layoutChild(field, font.getWidth(), font.getHeight());
setPositionChild(field, getGap(), 5);
width = Math.min(width, getPreferredWidth());
height = Math.min(height, getPreferredHeight());
setExtent(width, height);
}
public int getPreferredHeight() {
return 70;
}
public int getPreferredWidth() {
return Display.getWidth();
}
protected void paint(Graphics graphics) {
int rectHeight = getPreferredHeight();
int rectWidth = getPreferredWidth();
graphics.drawRect(0, 0, rectWidth, rectHeight);
super.paint(graphics);
}
private int getGap() {
return ((getPreferredWidth() / 4) - font.getWidth()) / 2;
}
public void fieldChanged(Field field, int context) {
if (field == sharebtn) {
} else if (field == commentbtn) {
Main.getUiApplication().pushScreen(new Main_Comments());
} else if (field == otherbtn) {
Main.getUiApplication().pushScreen(new Menu_Others());
}
}
public boolean keyDown(int keycode, int status) {
if (Keypad.key(keycode) == Keypad.KEY_ESCAPE) {
delete(slider);
return true;
}
return super.keyDown(keycode, status);
}
}
}
Above is the code that display a screen. In fontbtn, When click will change the variable true / false. However, it cannot update instant to display the field slider.
slider is something like seekbar in Android. In android, when click then can setvisibility but not blackberry RIM, so how to control it?
First of all, I would recommend not using variables with names like this if you can avoid it:
private boolean a;
Try to give it a name that's more descriptive, as that will help us understand your code better.
Next, it looks like you are testing the variable a before it ever has a chance to change, in the Main_NewsDetail constructor. So that won't work. Maybe try this in the Main_NewsDetail class:
/** separate boolean used because Field.isVisible() doesn't seem totally robust */
private boolean isSliderVisible = false;
private void setSliderVisible(boolean isVisible) {
if (isVisible != isSliderVisible) {
if (isVisible) {
add(slider);
} else {
delete(slider);
// but, we still retain the "slider" member variable, so it can be
// added again later
}
isSliderVisible = isVisible;
// I'm not actually sure that this is needed. I include it because I can't run this code right now!
invalidate();
}
}
Then, in your button click handler:
fontbtn = new Custom_ButtonField(font, fontactive, fontactive) {
protected boolean navigationClick(int status, int time) {
setSliderVisible(!isSliderVisible);
return true;
}
};
Now, this code can work because your Main_NewsDetail has only one Field in it, the slider. If there are actually multiple Field objects (which you probably will have), then you may need more complicated logic. You may want to show the slider in the same location every time. For that, you can record the index of the slider, in the list of all the Main_NewsDetails fields (for example, is the slider the 1st field, the 2nd, the 5th?). Then, instead of calling add(slider), you would do:
private void setSliderVisible(boolean isVisible) {
if (isVisible != isSliderVisible) {
if (isVisible) {
insert(slider, sliderIndex);
You might need to make Main_NewsDetail a subclass of Manager and implement the sublayout() method. That way, you can make sure that if isSliderVisible, you always lay out the slider in the same position.
Try calling Manager's invalidate-method to force a repaint for the managed area:
Marks this entire manager as requiring repainting.
Invoke this method to signal that this manager's entire region requires repainting.
I built custom edit field because i want to change the background color.
first, second and third shown unstable, sometime display when focusing, disappear when lost focusing.
I want the result like third image where the focusing at where also static display all the field.
Here is my Custom_EditField:
public class Custom_EditField extends EditField {
private int width, row, color;
private boolean isfocus;
Custom_EditField(long style, int width, int row) {
super(style);
this.width = width;
this.row = row;
}
public int getPreferredHeight() {
return Font.getDefault().getHeight() * row;
}
public int getPreferredWidth() {
return width;
}
protected void onFocus(int direction) {
color = Color.GRAY;
isfocus = true;
}
protected void onUnfocus() {
color = Color.GOLD;
isfocus = false;
}
protected void layout(int maxWidth, int maxHeight) {
super.layout(maxWidth,
Math.min(maxHeight, Font.getDefault().getHeight() * row));
super.setExtent(maxWidth,
Math.min(maxHeight, Font.getDefault().getHeight() * row));
}
protected void paint(Graphics graphics) {
int rectHeight = getPreferredHeight();
int rectWidth = getPreferredWidth();
try {
if (isfocus) {
graphics.setBackgroundColor(color);
} else {
graphics.setBackgroundColor(color);
}
color = Color.BLACK;
graphics.setColor(color);
graphics.drawRect(0, 0, rectWidth, rectHeight);
super.paint(graphics);
} finally {
graphics.setColor(color);
}
}
}
I'm not 100% sure which problem you're asking about:
how to draw your own focus background colors for an EditField, or
how to fix the problem with fields disappearing as you move focus
1) If it's the second problem (disappearing), then I would guess that you're having the same problem as in your other question, with the Custom_TopField buttons disappearing
So, if these Custom_EditField objects are created by a manager that extends VerticalFieldManager, but also implements sublayout() itself to perform all the positioning, then try the solution I suggested in the other question (don't extend VerticalFieldManager, just extend Manager).
2) If that doesn't work, it's possible that your paint() method is not getting triggered when it should. Try adding a call to invalidate() in your focus methods, along with a call to the superclass methods onFocus() and onUnfocus():
protected void onFocus(int direction) {
color = Color.GRAY;
isfocus = true;
invalidate();
super.onFocus(direction);
}
protected void onUnfocus() {
color = Color.GOLD;
isfocus = false;
invalidate();
super.onUnfocus();
}
3) And, you might need to implement this, too:
public boolean isFocusable() {
return true;
}
But, first, check your manager class, to be sure this isn't the same problem as in your other question.
Also ...
In this class, you are basing the height of the edit field on the row number. Is this really what you want? Row 0 would be 0 size, and each row after that would get taller and taller. Is that really the UI? Normally, you would have all the rows' edit fields be the same size, and simply lay them out with a different y offset. Most likely, this class should not need to know which row it has been placed on. That information is normally the responsibilty of a manager object.
protected EditField getEditField() {
EditField edit_field = new EditField("", "", 10, EditField.NO_NEWLINE
| BasicEditField.FIELD_VCENTER) {
protected boolean navigationClick(int status, int time) {
}
protected void onFocus(int direction) {
Set the boolean during focus
}
protected void onUnfocus() {
}
protected void paintBackground(Graphics graphics_paint) {
if(that boolean is true)
{
Set your custom background during focus.
}else{
Set your custom background during unfocus.
}
}
protected void paint(Graphics graphics_paint) {
int old_color = graphics_paint.getColor();
try {
if(that boolean is true)
{
Set your custom Font color during any event like focus and click.
}else{
Set your custom background Font color during any event like unfocus.
}
super.paint(graphics_paint);
} finally {
graphics_paint.setColor(old_color);
}
}
public void layout(int width, int height) {
}
};
I have been having this annoying problem when trying to implement a picture gallery on BlackBerry 6.
Everything works, however when the focus changes from the top buttons to say the pictures further down the screen, the images seem to glitch and not paint themselves correctly. Please see the images below for an example:
(Focus is on the top of the screen(not shown))
(Focus is now on the bottom left image, note that the top image is now blank for an unknown reason)
And this happens no matter how many pictures I add to the tumbnail gallery.
Now here is my code, (a part of it concerning the drawing of the thumbnails)
public ProductImage(String productName){
super(VERTICAL_SCROLL|VERTICAL_SCROLLBAR);
currentProduct = productName;
createGUI();
}
public void createGUI(){
deleteAll();
try{
Storage.loadPicture();
}catch(NullPointerException e){
e.printStackTrace();
}
this.setTitle(new LabelField(_resources.getString(PRODUCT_IMAGE), Field.FIELD_HCENTER));
if(ToolbarManager.isToolbarSupported())
{
Toolbar tb = new Toolbar();
setToolbar(tb.createToolBar());
}
else{
Toolbar tb = new Toolbar();
add(tb.createNavBar());
}
picVector = Storage.getPicture(currentProduct);
EncodedImage enc = EncodedImage.getEncodedImageResource("camera.png");
EncodedImage sizeEnc = ImageResizer.sizeImage(enc, Display.getHeight(), Display.getHeight());
takenPicture = new BitmapField(enc.getBitmap());
vfMain = new VerticalFieldManager();
vfMain.add(logo);
vfMain.add(new SeparatorField());
add(vfMain);
prepareBmpFields();
}
private void prepareBmpFields() {
System.out.println("This is the vector size: " + picVector.getPicVector().size());
LayoutManager manager = new LayoutManager();
FieldChangeListener itemListener = new ButtonListener();
mBmpFields = new ImageButtonField[picVector.getPicVector().size()];
for (int i = 0; i < picVector.getPicVector().size(); i++) {
/*EncodedImage image = EncodedImage
.getEncodedImageResource((String)imageVector.elementAt(i));*/
byte[] data = getData((String)picVector.getPicVector().elementAt(i));
//Encode and Resize image
EncodedImage eImage = EncodedImage.createEncodedImage(data,0,data.length);
eImage = ImageResizer.resizeImage(eImage, mImgWidth, mImgHeight);
ImageButtonField currentImage = new ImageButtonField(eImage.getBitmap());
currentImage.setAssociatedPath((String)picVector.getPicVector().elementAt(i));
mBmpFields[i] = currentImage;
mBmpFields[i].setChangeListener(itemListener);
manager.add(mBmpFields[i]);
}
vfMain.add(manager);
}
private class LayoutManager extends VerticalFieldManager {
public LayoutManager() {
super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
}
protected void sublayout(int width, int height) {
int columns = mScrWidth / (mImgWidth + 2 * mImgMargin);
int scrWidth = Display.getWidth();
int rows = mBmpFields.length / columns
+ (mBmpFields.length % columns > 0 ? 1 : 0);
int counter = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
int posX = j * (mImgWidth + 2 * mImgMargin) + mImgMargin;
int posY = i * (mImgHeight + 2 * mImgMargin) + mImgMargin;
if(mBmpFields.length > counter){
Field field = mBmpFields[counter];
layoutChild(field, mImgWidth, mImgHeight);
setPositionChild(field, posX, posY);
counter++;
};
}
}
if(Display.getWidth() < Display.getHeight()){
setExtent(mScrWidth, (int)(mScrHeight*1.25));
}
else{
setExtent(mScrWidth, (int)(mScrHeight*2));
}
}
public int getPreferredWidth() {
return mScrWidth;
}
public int getPreferredHeight() {
return mScrHeight;
}
}
}
I have removed many non relevant parts of the code, but the needed code is there.
Does anyone know what could be causing this problem? Thanks for your help!
Edit: as requested, here is my implementation of ImageButtonField class:
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.BitmapField;
public class ImageButtonField extends BitmapField{
String associatedPath ="";
BitmapField image2;
public ImageButtonField(Bitmap image) {
super(image);
}
public void setAssociatedPath(String path){
associatedPath = path;
}
public String getAssociatedPath(){
return associatedPath;
}
public boolean isFocusable() {
return true;
}
protected void applyTheme(Graphics arg0, boolean arg1) {
}
protected void drawFocus(Graphics graphics, boolean on) {
}
protected void onFocus(int direction) {
// only change appearance if this button is enabled (aka editable)
if (isEditable()) {
invalidate(); // repaint
}
super.onFocus(direction);
}
public void onUnfocus() {
invalidate(); // repaint
super.onUnfocus();
}
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
protected boolean trackwheelClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
protected void paint(Graphics graphics) {
super.paint(graphics);
if (isFocus()) {
graphics.setGlobalAlpha(128);
graphics.setColor(0x888888);
graphics.fillRect(0, 0, getWidth(), getHeight());
}else{
graphics.setGlobalAlpha(0);
graphics.setColor(0x000000);
graphics.fillRect(0, 0, getWidth(), getHeight());
//graphics.drawBitmap(0, 0, getWidth(), getHeight(), image2.getB, 0, 0);
}
}
protected boolean keyChar(char character, int status, int time) {
if(Characters.ENTER == character || Characters.SPACE == character) {
fieldChangeNotify(0);
return true;
}
return super.keyChar(character, status, time);
}
}
Ok, so you can disregard my first answer, but since I didn't have your ImageButtonField code at the time, I don't want to throw it out ... maybe someone else will find it useful.
In the end, I didn't need to make any changes to ImageButtonField, but I did change your LayoutManager class. The way I figured out that it was the problem was I just started replacing your custom UI classes with built-in ones. I replaced ImageButtonField with BitmapField. That didn't fix it. Then, I replaced LayoutManager with FlowFieldManager and that fixed it. So, I knew where the problem was.
My solution:
private class LayoutManager extends Manager {
public LayoutManager() {
super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
}
protected void sublayout(int width, int height) {
setExtent(width, height);
// TODO: maybe always set the same virtual extent?
if (Display.getWidth() < Display.getHeight()) {
setVirtualExtent(mScrWidth, (int) (mScrHeight * 1.25));
} else {
setVirtualExtent(mScrWidth, (int) (mScrHeight * 2));
}
int columns = mScrWidth / (mImgWidth + 2 * mImgMargin);
// int scrWidth = Display.getWidth();
int rows = mBmpFields.length / columns + (mBmpFields.length % columns > 0 ? 1 : 0);
int counter = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
int posX = j * (mImgWidth + 2 * mImgMargin) + mImgMargin;
int posY = i * (mImgHeight + 2 * mImgMargin) + mImgMargin;
if (mBmpFields.length > counter) {
Field field = mBmpFields[counter];
layoutChild(field, mImgWidth, mImgHeight);
setPositionChild(field, posX, posY);
counter++;
}
}
}
}
public int getPreferredWidth() {
return mScrWidth;
}
public int getPreferredHeight() {
return mScrHeight;
}
}
I can't say for sure that I understand why your original code wasn't working, but I can say that I wouldn't have done a few of the things in the original code:
The original code was extending VerticalFieldManager but was doing all the work itself, in sublayout(). So, I don't think there was any point extending VerticalFieldManager. I changed it to just extend Manager.
The original code was calling setExtent() with different sizes. I don't think that's what you wanted. Extent is the actual size of the Field. Virtual extent is the virtual size, which is what you want to set larger than the actual extent, in order to enable scrolling. You don't need to dynamically calculate different extents for portrait vs. landscape because the width and height parameters passed to sublayout() will already reflect that. I'm not sure you really even need to be setting different virtual extents either. I think you should probably always set the virtual extent height to the number of rows times picture height, accounting for margins.
You had an unused variable scrWidth in your original code. I commented it out above.
You also posted this question recently, right? Am I correct in assuming that the ImageButtonField you refer to here is the same one you were working on in the other question?
I can't see your full implementation of ImageButtonField, which you should probably post here, too. However, looking at the answers to your other question, I have a feeling that you're doing some custom focus handling in ImageButtonField, and maybe it's not being done quite right. In any case, that class may be where the problem is.
I have a similar Field subclass of my own, and here are the focus handling methods I define:
public class CustomButtonField extends Field {
private Bitmap _button; // the currently displayed button image
private Bitmap _on; // image for 'on' state (aka in-focus)
private Bitmap _off; // image for 'off' state (aka out-of-focus)
protected void onFocus(int direction) {
// only change appearance if this button is enabled (aka editable)
if (isEditable()) {
_button = _on;
invalidate(); // repaint
}
super.onFocus(direction);
}
protected void onUnfocus() {
_button = _off;
invalidate(); // repaint
super.onUnfocus();
}
protected void drawFocus(Graphics graphics, boolean on) {
// override superclass implementation and do nothing
}
public boolean isFocusable() {
return true;
}
I also have a custom implementation of paint(). I won't show it all here, because a lot of the code probably has nothing to do with your problem, but my paint() does include this call:
graphics.drawBitmap(_padding, _padding, _fieldWidth, _fieldHeight, _button, 0, 0);
You might not care about the fact that I have separate images for focused, and unfocused states ... maybe you show the same image at all times.
But, probably the thing to check is your onFocus() and onUnfocus() methods. You may need to add a call to invalidate() as I have.
Looking at Rupak's answer to your other question, it would also be good to check your ImageButtonField.paint() method, and make sure you aren't neglecting to do important drawing steps if the field is not in focus.
How to draw focus to a VerticalFieldManager in BlackBerry.
I have tried this but not working.
VerticalFieldManager vv=new VerticalFieldManager(Manager.focusFOCUSABLE);
You can try calling Field.setFocus on it, but since a manager is a container, I'm not sure you are going to see "the focus" over it.
If it doesn't work, you can try also overriding the paint method and draw your own custom focus when isFocus returns true.
this is the way to do it:
VerticalFieldManager vv=new VerticalFieldManager(FOCUSABLE) {
protected void paintBackground(Graphics g) {
int prevColor = g.getColor();
int bgColor;
if (isFocus()) {
bgColor = Color.Blue;
} else {
bgColor = Color.White;
}
g.setColor(bgColor);
g.fillRoundRect(0, 0, getPreferredWidth(), getPreferredHeight(), 0, 0);
g.setColor(prevColor);
}
public void onFocus(int direction) {
super.onFocus(direction);
this.invalidate();
}
public void onUnfocus() {
super.onUnfocus();
this.invalidate();
}
};
_focusAnchor = new NullField(FOCUSABLE);
add(_focusAnchor);
try this -
VerticalFieldManager vv=new VerticalFieldManager(FOCUSABLE);
then add items to the vv.
I am having 2 EditFields in my login form with names Email: and Password:. Just below email I have login button. Suppose I come down till login, I can scroll back only till password field.The cursor fails to reach Email field. In simulator, I tried using arrow keys as well as trackpad. Please help how to scroll back to first editfield
AbsoluteFieldManager ab = new AbsoluteFieldManager();
add(ab);
new SeparatorField();
et=new EditField("Email-id:","");
pwd=new PasswordEditField("Password:","");
ab.add(et,35,110);
ab.add(pwd,35,150);
I am using AbsoluteFieldManager and developing for OS 6.0. I want the loginscreen to look like facebook login page.
Kindly let me know what can possibly be the reason for not able to scroll up
Maybe it is a RIM bug with the AbsoluteFieldManager. Never used it before so I don't know about it. You can create a work around to solve this problem. Find it below:
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);
}
}
};
In this way, when you arrive to the first element in the password edit field, you will oblige the email field to get focused. This will work for you as a work around.
Another way to solve the problem is to add the two fields in an horizontal field manager, in that way I guess this will work for you for sure. If not use the first method. You can find below the code for HorizontalFieldManager:
et=new EditField("Email-id:","");
pwd=new PasswordEditField("Password:","");
HorizontalFieldManager manager = new HorizontalFieldManager();
manager.add(et);
manager.add(pwd);
ab.add(manager, yourX, yourY);
It also may be a RIM bug. What OS do you use? Is it OS 5+? Do you use custom paddings/margins/borders for some of the UI elements on the screen (including the screen itself)? If yes, try to comment out any code that sets paddings/margins/borders to check whether this it the case.
You can use this code for your login page:
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
}
}}
What you have described is not normal behavior.
My conclusion is that your code has one or more bugs, in order to solve your problem you should modify your code to fix the bugs. You will then be able to scroll up and down through the various fields.
note: As this question stands it's not possible for me to be more specific about the exact bugs. So instead I will show you an example of the layout you described that would scroll properly and you can use as a default to determine which of your deviations have caused your bugs.
// inside MainScreen constructor
add(new EditField("Username:","",0));
add(new EditField("Password:","",0));
add(new ButtonField(buttonBMP,ButtonField.CONSUME_CLICK));