[英]how to display this kind of quotes « … »?
我正在研究应用程序的项目。
我要显示以下引号:«和»。 但它显示数字:2131296435和2131296434。
它们的值(«和»)在XML文件中:
<string name ="open_quote">«</string>
<string name ="close_quote">»</string>
在我的Java代码中,我有类似以下内容:
text.setText(R.string.open_quote+aStringValue+R.string.close_quote);
尝试使用以下内容:
<string name ="open_quote">\u00ab</string>
<string name ="close_quote">\u00bb</string>
您还应该像这样设置Text,因为每个字符串值都作为Integer值保存到R.java中:
text.setText(getString(R.string.open_quote) + "text" + getString(R.string.close_quote));
在您的xml文件中,
尝试使用HTML实体: «
用于«和»
为»
或等效的Unicode字符: «的 \«
和»»的 \»
谢谢您的帮助。
我发现错误不是来自xml文件,而是来自我的Java代码
应该是 :
getResources().getString(R.string.open_quote)
代替 :
R.string.open_quote
在xml中,两者均有效:
<string name ="open_quote">\u00ab</string>
<string name ="close_quote">\u00bb</string>
要么
<string name ="open_quote">«</string>
<string name ="close_quote">»</string>
所以在我的代码中,我有: text.setText(getResources().getString(R.string.open_quote)+aStringValue+getResources().getString(R.string.close_quote));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.