【问题标题】:Quotation marks not shown on display引号未显示在显示屏上
【发布时间】:2016-03-28 20:28:43
【问题描述】:

在我的字符串 xml 文件中,我有这样一行:

<string name="infoHeader">random "text" here</string>

但它只显示为

此处为随机文本

在手机的显示屏上,即不带引号。

我通过谷歌阅读了它,并尝试了一些 HTML 样式:

<string name="infoHeader">random &quot;text&quot; here</string>

然后使用:

String hej = res.getString(R.string.infoHeader);     
Spanned marked_up = Html.fromHtml(hej);
((TextView)findViewById(R.id.infoHeader)).setText(marked_up, BufferType.SPANNABLE);

但它仍然不起作用。我尝试了一些其他的 HTML,比如&amp;lt;i&gt;text&amp;lt;/i&gt;,效果很好。怎么了?

【问题讨论】:

    标签: android html xml


    【解决方案1】:

    试试这个:

    <string name="infoHeader">random \"text\" here</string>
    

    【讨论】:

    • 谢谢,这行得通。奇怪的是我在网上找不到这个简单的技巧。
    【解决方案2】:

    试试这个:

      Value:  \"Hello\" 
    

    在资源窗口中,或

    <string name="hello">\&quot;Hello\&quot;</string>
    

    在xml文件中

    【讨论】:

      【解决方案3】:

      我不确定发生了什么,但我尝试了其他几种逃生方式。

      这对我有用:

      <string name="hello">Hello \"World,\" ActivityHello!</string>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-06
        • 1970-01-01
        • 2020-12-18
        • 2011-04-24
        • 2010-10-19
        • 1970-01-01
        相关资源
        最近更新 更多