Android examples for android.text:SpannableString
format string by style using SpannableString
import android.content.Context; import android.text.SpannableString; import android.text.style.TextAppearanceSpan; public class Main{ public static SpannableString format(Context context, String text, int style) { SpannableString spannableString = new SpannableString(text); spannableString.setSpan(new TextAppearanceSpan(context, style), 0, text.length(), 0);// ww w. j a v a 2 s . c om return spannableString; } }