08-21-2009 05:28 AM
Hi all,
I am going to custom the RichTextField to show the html strings, I have to overwrite the paint() method and draw text line by line. However, I don't know when the text is going to be out of field region, then I can draw the text left in the new line. How can the RichTextField do that? Does anybody know the solution for this?
Thank you.
Binh Nguyen.
08-21-2009 09:41 AM
Good luck with this. You will need to determine exactly what you need to display, the extent of the Field, then use Font.getAdvance(..) to determine what will fit, You need to break it where it doesn't fit (and you will probably want to break on a separator line a space) and then start the next line. All a lot of fun. I'm sure there there is some code out there, but this seems like a difficult choice.
Perhaps something like a BrowserField will help you. Never used on myself, but I'm sure that you can have a Field that takes the html and processes it for you.
08-21-2009 12:52 PM
Thanks Peter, but BBdeveloper confirmed with me that it requires a html file before adding to BrowserField. I have a lot of html strings, so I have to save each string to a html file, it's really terrible.
Now, I am going with TextField.drawText(), I can catch the position and the length of each line, hope that I can draw text from that informs.
Will let you know soon...
Regards.
08-21-2009 01:07 PM - edited 08-21-2009 01:08 PM
08-21-2009 01:19 PM
08-26-2009 05:26 AM
Hi all,
How can we add a new line to a RichTextField, something like the About page of BB:
BlackBerry 9000
smartphone (3G, Wifi)
....
Or I have to add a new RichTextField for a new paragraph. I intend to use ListField, but I am afraid that it will be truncated when the string is too long.
Thank you,
Binh Nguyen
08-26-2009 06:45 AM
thanhbinh84 wrote:Hi all,
How can we add a new line to a RichTextField, something like the About page of BB:
BlackBerry 9000
smartphone (3G, Wifi)
....
Or I have to add a new RichTextField for a new paragraph. I intend to use ListField, but I am afraid that it will be truncated when the string is too long.
Thank you,
Binh Nguyen
I can do it now, just add '/n' to the string where you want to start a new paragraph before adding to the RichTextField.
Regards.