Friday, April 22, 2011

Formatting text in TextView

Some simple html formatting can be applied to the TextView's text rendering. For example ...

String aHeading="...";
String aTextBody="...";
StringBuffer aBuf=new StringBuffer("<b>");
aBuf.append(aHeading);
aBuf.append("</b><br/>");
aBuf.append(aTextBody);

TextView aTextView=(TextView)aView.findViewById(...);aTextView.setText(Html.fromHtml(aBuf.toString()));