Tweet o = tweets.get(position);
TextView tt = (TextView) v.findViewById(R.id.toptext);
//TextView bt = (TextView) v.findViewById(R.id.bottomtext);
EditText bt =(EditText)findViewById(R.id.bottomtext);
bt.setText(o.author);
Spannable spn = (Spannable) bt.getText();
spn.setSpan(new StyleSpan(android.graphics.Typeface.BOLD_ITALIC)
, 0, 100, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
//bt.setText(o.author);
tt.setText(o.content);
I'm setting twitter data in my Android application. I want to make the font bold and italic using Spannable but it does not work, giving an error. How can I do it?
The easy way to create a
spannable
textbold
anditalic
to set into yourTextView
is using the methodHtml.fromHtml()
:and using the html elements
<b>
and<i>
or the html elements
<strong>
and<em>
for this u will need to make
o.content
text asSpannableString
then set it to TextView as :EDIT : you can also use Html.fromHtml for making text Bold and Italic in textview as :