Bold text that I charge for SharedPreferences

1

I try to put in bold only the text I receive from SharedPreference but I do not know how to do it correctly, this is what I have always done but on a text, not on one loaded with SharedPreferences and so I see It is possible.

conf.setText(Html.fromHtml("Hola," + " " + <b> prefs.getString("nombrepersona", "") </b> + "," + " " + "texto2");

Can someone help me? The error is clear, it does not recognize < b > < / b>

    
asked by UserNameYo 05.06.2017 в 22:51
source

1 answer

3

It should be done in this way:

 conf.setText(Html.fromHtml("Hola,  <b>" + prefs.getString("nombrepersona", "") + "</b>, texto2");

It is not necessary to concatenate several strings, and remember that html tags are converted, therefore they must be defined as string.

    
answered by 05.06.2017 / 23:36
source