Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a String text Bold in Java Android

I want to make Habit Number: bold , I tried the HTML tag but it didn't work. I did some research but couldn't find any. Hope someone is able to help me. Thanks!

String habitnumber = "Habit Number: " + String.valueOf(habitcounter);
String Title = habit.getTitle();
String description = habit.getDescription();


//Set text for the row
                tv.setText(habitnumber+ "\n" + Title + " \n" + description + "\n --------------------");
like image 953
meskh Avatar asked Jun 08 '14 21:06

meskh


2 Answers

I tried the HTML tag but it didn't work

I think that you didnt wrap your string to Html.fromHtml

solution:

You can do it with HTML using html tag for bold: <b>

 String habitnumber = "<b>" + "Habit Number: " + "</b> " + String.valueOf(habitcounter);
 tv.setText(Html.fromHtml(habitnumber ));
like image 164
Rod_Algonquin Avatar answered Sep 18 '22 18:09

Rod_Algonquin


tv.setTypeface(null, Typeface.BOLD);
like image 28
JaKoZo Avatar answered Sep 19 '22 18:09

JaKoZo