tags:

views:

297

answers:

3

Hello Everyone.. I am making an application in blackberry with 4.7 OS. In my project i need to put a labelfield on top of a bitmapfield. I have taken the bitmapfield inside a verticalfieldmanager. I wanted a complete code for this problem.

Thanks in advance.

+1  A: 

You can create your own class extends BitmapField and override method paintBitmap().

Like this:

public class MyBitmapField extends BitmapField {
//...       
protected void paintBitmap(Graphics g, int arg1, int arg2, int arg3,
        int arg4, Bitmap arg5, int arg6, int arg7) {            
    super.paintBitmap(g, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
    g.drawText("Your text", 5,5 );  
}

// ...

}

Also you can override drawFocus(), paintBackground() and other.

Yeti
+1  A: 

Also you could draw text over bitmap:

class Scr extends MainScreen {
    Bitmap bmp = new Bitmap(200, 100);

    public Scr() {
        //draw bitmap
        Graphics g = new Graphics(bmp);
        g.drawLine(0, 0, 199, 99);
        g.drawLine(199, 0, 0, 99);

        //draw text
        Font f = getFont().derive(Font.PLAIN, 15);
        g.drawText("hello", 0, (bmp.getHeight() - f.getHeight()) >> 1, 
            DrawStyle.HCENTER|DrawStyle.VCENTER);
        add(new BitmapField(bmp));
    }
}

Other way is to implement custom layout like in Blackberry - fields layout animation

Max Gontar
A: 

So, can we create (extend) a Manager class (maybe) that has two UI field and setPosition one field on top of each other? Is it a 'good design' to do that? Thank you.

pradana