android - How to make certain parts of the textview to look bold? -


i'm fetching data contacts , displaying in textview. want 1 part t in bold.how that. tried doing this: sb.append(html.fromhtml("\n"+" contact name:" + name); it's not working..can please me

you need format string in html form during creation apply formhtml method on whole string. html.formhtml() method returns displayable styled text(spanned) provided html string. if applying method on substring(with html tags) after appending them stringbuffer, sb.append(html.fromhtml("\n"+" < b>contact name< /b>:" + name) calls spanned.tostring() method resulting in removal of html tags hence viewing plain text in text view.

try way solve problem

     stringbuffer sb=new stringbuffer();      sb.append("hello");      sb.append("<b>how</b>");      sb.append("are you");      tv.settext(html.fromhtml(sb.tostring())); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -