08-21-2012 06:19 AM
Hi
I have a ButtonField on screen. I want to set Background color of the button orange and Text color black. When Buttonfield is in focus color of text should be changed to white. How to do this?
I have used following code. In this code m unable to set background color to whole button. It is set only to area behind text.
ButtonField btn = new ButtonField("Test",ButtonField.USE_ALL_WIDTH|Butto
{
boolean focused = false;
protected void paint(Graphics graphics)
{
graphics.setBackgroundColor( 0x00D8632E );
if(focused)
graphics.setColor(Color.WHITE);
else
graphics.setColor(Color.BLACK);
graphics.clear();
super.paint(graphics);
}
protected void onFocus(int direction)
{
focused = true;
}
protected void onUnfocus()
{
focused = false;
};
};
08-21-2012 06:52 AM - edited 08-21-2012 06:52 AM
Hi,
Try this once
ButtonField btn = new ButtonField("Test",ButtonField.USE_ALL_WIDTH|Butto nField.FIELD_HCENTER)
{
boolean focused = false;
protected void paint(Graphics graphics)
{
graphics.setColor(color);
graphics.setBackgroundColor(0x00D8632E );
super.paint(graphics);
}
protected void onFocus(int direction)
{
color = Color.WHITE;
invalidate();
}
protected void onUnfocus()
{
color = Color.BLACK;
invalidate();
};
};
Regards,
Lakshman K
08-21-2012 07:00 AM
08-21-2012 07:11 AM
08-21-2012 10:13 AM
For this you have to customized the button field.
08-25-2012 12:34 PM
Just override the ApplyTheme method of button field.
and paint the desired background inPaint function.