views:

895

answers:

1

Hi to All,

I have created a customized BasicEditField with Border using Bitmap.Now while typing the text,it crosses the border of the BasicEditField.This is my code

class customEditField1 extends EditField

{

 Bitmap mBorder = null;
 customEditField1(Bitmap borderBitmap) 
 {
    mBorder = borderBitmap;
 }
 protected void paint(Graphics graphics) 
 {
     graphics.drawBitmap(0, 0, mBorder.getWidth(),mBorder.getHeight(), mBorder, 0, 0);
     super.paint(graphics);
 }

}

I want to create a BasicEditField which should hide the previously entered text and displays the newly entered text and the typed text should be with in the border.It should not depends on the number of chars limit.And i want to Apply padding between the text and the border.

+1  A: 

You can put BasicEditField into HorizontalFieldManager.
Don't forget to move border bitmap painting from BasicEditField to HorizontalFieldManager.

class ScrollEdit extends HorizontalFieldManager {
    Bitmap mBorder = null;
    public BasicEditField mEdit = null;

    public ScrollEdit(Bitmap border) {
     super(HORIZONTAL_SCROLL | NO_HORIZONTAL_SCROLLBAR);
     mBorder = border;
     mEdit = new EditField(BasicEditField.NO_NEWLINE);
     add(mEdit);
    }

    protected void paint(Graphics graphics) {
     graphics.drawBitmap(0, 0, mBorder.getWidth(), mBorder.getHeight(),
       mBorder, 0, 0);
     super.paint(graphics);
    }

}

But you will have to play around with layout and setExtent to size manager and edit correctly. My advice is to try it without border bitmap first.

See Scroll BasicEditField instead of wrap

Talking about the wrap, set padding to BasicEditField within manager or add white space in border bitmap...

Max Gontar
I dont know how to move border bitmap from BasicEditField to HorizontalFieldManager?
Rajapandian
Take a look at code provided, it's already there in paint(), I've just drown your attention to it.
Max Gontar