Color Change LabelField
I have a vertical field manager, inside it are numerous horizontal field manager. in each horizontal field manager there are 1 bitmapfield and another verticalfield manager ( 3 label fields).
I was able to change the background color(GRADIENT) of the horizontal fieldmanager to which ev开发者_运维知识库er has the focus. But i want to change the color (WHITE) of the labelfields within that manager on focus and change back the color (BLACK) when unfocus. Also, the isFocus() doesnt work on paint for both manager and label field.
Try this
LabelField rtf=new LabelField(list[i],Field.FOCUSABLE|Field.USE_ALL_WIDTH)
{
boolean _inFocus = false;
public void onFocus(int direction) {
_inFocus = true;
super.onFocus(direction);
this.invalidate();
}
public void onUnfocus() {
_inFocus = false;
super.onUnfocus();
this.invalidate();
}
public void paint(Graphics g)
{
if (_inFocus ){
g.setBackgroundColor(0x6395CC);
g.clear();
g.setColor(Color.WHITE);
}
else
{
g.setBackgroundColor(Color.WHITE);
g.clear();
g.setColor(Color.BLACK);
}
g.clear();
super.paint(g);
}
};
精彩评论