Blackberry - single line BasicEditField with large text

。_饼干妹妹 提交于 2019-12-11 05:20:02

问题


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:


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...



来源:https://stackoverflow.com/questions/1158734/blackberry-single-line-basiceditfield-with-large-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!