strings.xml 无法让卢比符号正确显示
Can't get rupee symbol to show correctly from strings.xml
所以这很好用:
strFoo = "\u20B9" + strBar
但这不是
strFoo = R.string.rupee_symbol.toString() + strBar //.toString() is required
//R.string.rupee_symbol.toString() evaluates to some random number 2131755148... which I believe is a character array...
strings.xml
<string name="rupee_symbol">\u20B9 </string>
我不明白为什么会这样,看起来是一样的...!
您不应将字符串与字符串资源连接起来,您可以使用占位符:
<string name="rupee_symbol">\u20B9%s</string>
并使用:
strFoo = resources.getString(R.string.rupee_symbol, strBar)
使用getString(R.string.rupee_symbol)
代替R.string.rupee_symbol.toString()
For example-
String strBar = String.valueOf(100);
String strFoo = getString(R.string.rupee_symbol)+strBar;
textView.setText( strFoo);
所以这很好用:
strFoo = "\u20B9" + strBar
但这不是
strFoo = R.string.rupee_symbol.toString() + strBar //.toString() is required
//R.string.rupee_symbol.toString() evaluates to some random number 2131755148... which I believe is a character array...
strings.xml
<string name="rupee_symbol">\u20B9 </string>
我不明白为什么会这样,看起来是一样的...!
您不应将字符串与字符串资源连接起来,您可以使用占位符:
<string name="rupee_symbol">\u20B9%s</string>
并使用:
strFoo = resources.getString(R.string.rupee_symbol, strBar)
使用getString(R.string.rupee_symbol)
代替R.string.rupee_symbol.toString()
For example-
String strBar = String.valueOf(100);
String strFoo = getString(R.string.rupee_symbol)+strBar;
textView.setText( strFoo);