Pergunta

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!

Foi útil?

Solução

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);

Outras dicas

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));

Do you mean chinese?You may try like this:

TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top