【问题标题】:How to including a link in a body of text in android string resource如何在android字符串资源的正文中包含链接
【发布时间】:2016-09-07 18:26:55
【问题描述】:

我有一个名为 large_text 的字符串资源

<string name="large_text"> 
  "lots of texts"
  ...
  "lots more text\n\n"
  ...
  "I was not kidding"
  "so here is the phrase I want to make a hyperlink"
</string>

那么我如何将这么大的文本中的一个短语变成一个超链接呢? The suggestion here is not working: string.xml 甚至不会编译。它给出的错误是

错误:元素的内容必须由格式良好的字符组成 数据或标记。

【问题讨论】:

    标签: android android-layout android-resources


    【解决方案1】:

    即使我在从 strings.xml 使用它时也遇到了这个问题,所以我最终还是这样使用它,它对我有用。

     useageTerms.setText(Html.fromHtml("By tapping register, you agree to the\n " +
                "<a href=\"http://www.google.in/terms.html\">Terms & Conditions</a> for Google"));
     useageTerms.setMovementMethod(LinkMovementMethod.getInstance());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-18
      • 1970-01-01
      • 2014-11-28
      • 2019-01-25
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多