Title on mapfieldScreen in blackeberry is not visible

112 views Asked by At

enter image description here

I am creating a map app. in which i am using mapfield. on the MapFieldScreen I am trying to add Title and also creating tabs but these two things are not visible. instead there is just gray color on these two places..

Here is my code.

class MapFieldScreen extends MainScreen
{ 
MapFieldScreen()
{   
    title= new LabelField("My Trip",LabelField.FIELD_HCENTER|LabelField.USE_ALL_WIDTH)
    {
       protected void layout(int width,int height)
       {
            setExtent(UIConstants.SCREEN_WIDTH, getFont().getHeight()*2);
       }
       public void paint(Graphics g)
        { 
            g.setColor(Color.WHITE);             
            g.drawText(label,UIConstants.SCREEN_WIDTH*2/5,getFont().getHeight()/2);  
            super.paint(g); 
        }
    };
    setTitle(title);    
    mLoc= Bitmap.getBitmapResource(UIConstants.STOP);
    mmMapField = new MapField();

    add(mMapField);

}
}
1

There are 1 answers

1
Rupak On

You can check follwing code:

LabelField title = new LabelField("My Trip") {
    int _width = Display.getWidth();
    int _height = getFont().getHeight() * 2;

    protected void layout(int width, int height) {
        setExtent(_width, _height);
    }

    public void paint(Graphics graphics) {
        graphics.setColor(Color.WHITE);
        int xText = (_width - getFont().getAdvance(getText())) / 2;
        int yText = (_height - getFont().getHeight()) / 2;
        graphics.drawText(getText(), xText, yText);
    }
};

setTitle(title);