How do we set the background and font colors in a RichTextField? I tried to override the paint() method in addition to what has been described here, but when I scroll down i
In RIM 4.6 and greater you can use Background:
class ExRichTextField extends RichTextField {
int mTextColor;
public ExRichTextField(String text, int bgColor, int textColor) {
super(text);
mTextColor = textColor;
Background background = BackgroundFactory
.createSolidBackground(bgColor);
setBackground(background);
}
protected void paint(Graphics graphics) {
graphics.setColor(mTextColor);
super.paint(graphics);
}
}
For RIM 4.5 and lower use paint event to draw background youreself:
class ExRichTextField extends RichTextField {
int mTextColor;
int mBgColor;
public ExRichTextField(String text, int bgColor, int textColor) {
super(text);
mTextColor = textColor;
mBgColor = bgColor;
}
protected void paint(Graphics graphics) {
graphics.clear();
graphics.setColor(mBgColor);
graphics.fillRect(0, 0, getWidth(), getHeight());
graphics.setColor(mTextColor);
super.paint(graphics);
}
}
RichTextField mes_=new RichTextField("texto de ejemplo",Field.NON_FOCUSABLE){
protected void paint(Graphics g){
g.setColor(0x00e52f64);
super.paint(g);
}
};
mes_.setBackground(BackgroundFactory.createSolidBackground(0xFFFADDDA));
The method incrustaded in the declaration its for changing the color of the font. The method called after created its for changing the background to a solid color.