In my string xml file I have a line like this:
在我的字符串xml文件中,我有一个这样的行:
<string name="infoHeader">random "text" here</string>
But it is only displayed as
但它只显示为
random text here
随机文字在这里
on the phone's display, that is, without the quotation marks.
在手机的显示屏上,即没有引号。
I read about it via Google, and tried some HTML styling:
我通过谷歌阅读了它,并尝试了一些HTML样式:
<string name="infoHeader">random "text" here</string>
And then used:
然后使用:
String hej = res.getString(R.string.infoHeader);
Spanned marked_up = Html.fromHtml(hej);
((TextView)findViewById(R.id.infoHeader)).setText(marked_up, BufferType.SPANNABLE);
But it still doesn't work. I tried some other HTML, like <i>text</i>
, and that works just fine. What's wrong?
但它仍然无效。我尝试了一些其他的HTML,比如< i> text< / i>,这很好用。怎么了?
3 个解决方案
#1
9
Try this:
<string name="infoHeader">random \"text\" here</string>
#2
3
Try this:
Value: \"Hello\"
in the resources window, or
在资源窗口中,或
<string name="hello">\"Hello\"</string>
in the xml file
在xml文件中
#3
0
I'm not sure what's going on, but I tried a few other ways of escaping.
我不确定发生了什么,但我尝试了其他几种逃避方法。
This worked for me:
这对我有用:
<string name="hello">Hello \"World,\" ActivityHello!</string>
#1
9
Try this:
<string name="infoHeader">random \"text\" here</string>
#2
3
Try this:
Value: \"Hello\"
in the resources window, or
在资源窗口中,或
<string name="hello">\"Hello\"</string>
in the xml file
在xml文件中
#3
0
I'm not sure what's going on, but I tried a few other ways of escaping.
我不确定发生了什么,但我尝试了其他几种逃避方法。
This worked for me:
这对我有用:
<string name="hello">Hello \"World,\" ActivityHello!</string>