views:

530

answers:

3

Does anyone know how to set the background colour of just a section of text within a RichTextField on the Blackberry?

I already use the offsets, attributes and fonts arrays to make changes to the appearance of certain sections of the text, but I would like to add a highlight colour to the background of one section too.

I know there is a protected method called getBackgroundColors that returns an array of colors to be used, which I can overwrite. But I have tried this and that method never seems to get called in my code, I don't actually know how and when the underlying implementation of the RichTextField actually use this method. Any ideas?

A: 

You can extend the RichtextField and then in the paint method, you can paint the background and then call super.paint()

Ram
I want to highlight only a certain section of the text not paint the entire background one colour. You can already specify regions of the text to have different fonts, and I want to do the same for colours, e.g. specify that characters 10 through 20 should have a red background. I think that doing this with the paint method would involve too much complex calculations of where the desired section of text is currently positioned.
DaveJohnston
+1  A: 

So basically, it can't be done is the answer.

DaveJohnston