0

This is a string in strings.xml:

<string name="data_dd"><b>Data: </b>/string>

And this the java code:

myTextViews[pointer].setText(getResources().getText(R.string.data_dd) + data + "\n");

The problem is that the string data_dd is not bold in the textview. I tried also these but none of them worked:

<string name="data_dd"><Data><![CDATA[ <b>Data: </b> ]]> </Data></string>

myTextViews[pointer].setText(Html.fromHtml(getResources().getString(R.string.data_dd)) + data + "\n");

How can i do?

Thx in advance!

Gimmy88
  • 295
  • 2
  • 5
  • 13

3 Answers3

2

Try change :

myTextViews[pointer].setText(Html.fromHtml(getResources().getString(R.string.data_dd)) + data + "\n");

to :

myTextViews[pointer].setText(Html.fromHtml(getResources().getString(R.string.data_dd) + data + "\n"));

or test :

yourtextView.setTypeface(null, Typeface.BOLD);
VincentLamoute
  • 800
  • 1
  • 9
  • 16
0

Use below code if you want to set entire myTextViews[pointer] Bold:

in strings.xml

<string name="data_dd">Data: </string>

And in the TextView:

myTextViews[pointer].setTypeface(null,Typeface.BOLD);
myTextViews[pointer].setText(getResources().getText(R.string.data_dd) + data);

if you just want the heading "Data:" to be bold and rest of the text from variable "data" to be normal, then use:

myTextViews[pointer].setText(Html.fromHtml("<b>Data:</b>"+ data));
SKK
  • 5,261
  • 3
  • 27
  • 39
-1

Do you mean chinese?You may try like this:

TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);
JaveZh
  • 184
  • 3