[英]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.
但它显示数字:2131296435和2131296434。
Their value(« and ») are in an XML file: 它们的值(«和»)在XML文件中:
<string name ="open_quote">«</string>
<string name ="close_quote">»</string>
and in my Java code I have something like this: 在我的Java代码中,我有类似以下内容:
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,因为每个字符串值都作为Integer值保存到R.java中:
text.setText(getString(R.string.open_quote) + "text" + getString(R.string.close_quote));
In your xml file, 在您的xml文件中,
try using the HTML entities: «
尝试使用HTML实体:
«
for « and »
用于«和
»
for » 为»
or the equivalent Unicode characters: \«
for « and \»
for » 或等效的Unicode字符: «的
\«
和»»的 \»
You can use 您可以使用
text.setText("\u003C\u003C); // for <<
Checkout this for unicodes 检出unicode
https://unicode-table.com/en/#003C https://unicode-table.com/cn/#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 我发现错误不是来自xml文件,而是来自我的Java代码
It should be : 应该是 :
getResources().getString(R.string.open_quote)
instead of : 代替 :
R.string.open_quote
in xml, both works: 在xml中,两者均有效:
<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));
所以在我的代码中,我有:
text.setText(getResources().getString(R.string.open_quote)+aStringValue+getResources().getString(R.string.close_quote));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.