如何更改黑莓中对象选择字段的背景颜色?

时间:2012-03-08 12:54:16

标签: blackberry

我想更改黑莓中对象选择字段中所选项目的背景颜色吗?

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

尝试以下示例代码:

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);
        }
    }
}

我得到这样的结果:

Set Image on selected list