spannable on android for textView

I want to make the font bold and ıtalic with spannable

for this u will need to make o.content text as SpannableString then set it to TextView as :

SpannableString spannablecontent=new SpannableString(o.content.toString());
spannablecontent.setSpan(new StyleSpan(android.graphics.Typeface.BOLD_ITALIC), 
                         0,spannablecontent.length(), 0);
// set Text here
tt.setText(spannablecontent);

EDIT :
you can also use Html.fromHtml for making text Bold and Italic in textview as :

tt.setText(Html.fromHtml("<strong><em>"+o.content+"</em></strong>"));

Leave a Comment