Answer the question
In order to leave comments, you need to log in
How to bold a piece of text before a specific comma in Android?
For example, there is a text written to a String variable
String a = "Вася, Петя, Степа, Тостер, Ява, Вика, ***, ***, ***";
and so, separated by commas, 80 different words, numbers, etc. are written. String test = "Тостер, ВК, Пиво, Водка, Вопрос, Ответ, ****, ****"
int num = 1;
Answer the question
In order to leave comments, you need to log in
Spannable text = new SpannableString(test);
text .setSpan(new StyleSpan(Typeface.BOLD), 7, 9, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(text);
textView.setText(Html.fromHtml("Тостер, <strong>ВК</strong>, Пиво, Водка, Вопрос, Ответ, ****, ****"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question