0

I have a textview ,that contains different texts that can set dynamically.

different string likes

String s1="I am a Good boy";

String s2="I am a Bad` boy";

TextView tvnotificationstype=(TextView)view.findViewById(R.id.tv_notificationstype);

I using spanable but didnot get result

Typeface  fontbold = Typeface.createFromAsset(context.getAssets(), "fonts/SourceSansPro-Bold.ttf"); 

String[] sentence = s1.split(" ");
for(String word: sentence)
{
    if(word.contains("Good"))
    {
    Spannable spannable = new SpannableString(word);
        spannable.setSpan(fontbold , 0, 4, 0);
        tvnotificationstype.setText("I"+" "+"am"+" "+"a"+" "+spannable+"boy"); 
    }
}

I am using above code but i did not get the custom font effect .so please help me is there any mistake the above code.advance thanks for all

Ashok
  • 637
  • 2
  • 11
  • 24
  • Try use [CustomTypefaceSpan class](http://stackoverflow.com/questions/6612316/how-set-spannable-object-font-with-custom-font) to change typeface of part of string. – JK Park Apr 04 '14 at 09:01
  • above link worked fine but ,tvnotificationstype.setText("I"+" "+"am"+" "+"a"+" "+spannable+"boy") spannable not effect the font .this situation tvnotificationstype.setText(spannable) effect the custom font. any way thanks – Ashok Apr 04 '14 at 10:41

0 Answers0