Reputation: 477
I want to change background color of selected item in object choice Field in blackberry?
Upvotes: 0
Views: 684
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:
Upvotes: 1
Reputation: 8920
Read the BlackBerry API documents for Field.setBackground(Background background), Field.setBackground(int visual, Background background) and Background.
Upvotes: 2