Apple_Magic
Apple_Magic

Reputation: 477

How to change background color of object choice field in blackberry?

I want to change background color of selected item in object choice Field in blackberry?

Upvotes: 0

Views: 684

Answers (2)

alishaik786
alishaik786

Reputation: 3726

Try like this sample code:

public class SamplePopupScreen extends PopupScreen
{
    BitmapField bitmapField[];
    Bitmap bitmap=Bitmap.getBitmapResource("box-s6A.png");

    public SamplePopupScreen()
    {
        super(new VerticalFieldManager(),PopupScreen.DEFAULT_CLOSE);
        createGUI();
    }

    private void createGUI()
    {
        bitmapField=new BitmapField[3];
        add(new LabelField("Popup Screen",Field.FIELD_HCENTER));

        for(int i=0;i<3;i++)
        {
            VerticalFieldManager vr=new VerticalFieldManager(Field.FIELD_HCENTER|VERTICAL_SCROLL|VERTICAL_SCROLLBAR);

            bitmapField[i]=new BitmapField(null,Field.FOCUSABLE|Field.FIELD_HCENTER)
            {
                protected void paint(Graphics g)
                {
                    g.clear();
                    g.drawText("LabelNunber", 0, 0);
                    if(isFocus())
                    {
                        g.drawBitmap(0, 0, bitmap.getWidth(), bitmap.getHeight(), bitmap, 0, 0);
                        g.drawText("LabelNunber",0,0);
                    }
                }
                protected void layout(int width, int height)
                {
                    super.layout(250, 50);
                    setExtent(250, 50);
                }
            };
            vr.add(bitmapField[i]);
            add(vr);
        }
    }
}

and I am getting like this:

Set Image on selected list

Upvotes: 1

Related Questions