简体   繁体   中英

how to display this kind of quotes « … »?

I m working on a application's project.
I want to display this quotation marks : « and » . But it shows numbers: 2131296435 and 2131296434.

Their value(« and ») are in an XML file:

<string name ="open_quote">«</string>
<string name ="close_quote">»</string>

and in my Java code I have something like this:

text.setText(R.string.open_quote+aStringValue+R.string.close_quote);

Try using the following:

<string name ="open_quote">\u00ab</string>
<string name ="close_quote">\u00bb</string>

You also should set the Text like this as every string value is saved as an Integer value into R.java:

text.setText(getString(R.string.open_quote) + "text" + getString(R.string.close_quote));

Source

In your xml file,

try using the HTML entities: &laquo; for « and &raquo; for »
or the equivalent Unicode characters: for « and for »

You can use

text.setText("\u003C\u003C); // for <<

Checkout this for unicodes

https://unicode-table.com/en/#003C

thank you for your help.

I found out that the mistake didn't come from of my xml file , but in my java code

It should be :

getResources().getString(R.string.open_quote)

instead of :

R.string.open_quote

in xml, both works:

<string name ="open_quote">\u00ab</string>
<string name ="close_quote">\u00bb</string>

OR

<string name ="open_quote">«</string>
<string name ="close_quote">»</string>

So in my code, i have: text.setText(getResources().getString(R.string.open_quote)+aStringValue+getResources().getString(R.string.close_quote));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM