[英]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.