A lot of text is to be appended to a StringBuffer object. Later this text will be displayed on the page.
stringBuffer.append("A lot of text part 1");
stringBuffer.append("A lot of text part 2");
...
The text contains paragraph titles. Is it possible to format these titles before/after appending? Something like
stringBuffer.append("Title of text 1");
//in this line do some formatting to the above text, like make title bold, larger font, etc.
stringBuffer.append("A lot of text part 1");
I know that it can be done if I set TextViews in XML layout, but it’s just too many titles and this way would take so much time.
Not really sure what you want. You can use
String.formatto insert the text and surround it with w/e that is you want, like this:I’m still not sure if that’s what you’re asking.
I think you’ll find
StringBuilder.insert()useful.Do you know what part of the text is the title and what part is the body ?
Also consider
StringBuilderinstead ofStringBuffer. Read the javadoc documentation about it.