【问题标题】:Android: linebreak not working in textviewAndroid:换行符在 textview 中不起作用
【发布时间】:2014-12-21 12:53:19
【问题描述】:

我有一个字符串数组:

String[] articles = getArticles();

// articles[0] = "1. With the mixtures<br />2. Colors and others<br />";
// articles[1] = "3. Categories and people<br />4. Health and fitness";

StringBuilder sb = new StringBuilder();

for (String text : articles) {
   sb.append(text);
}

String content = sb.toString();
Spanned spanned = Html.fromHtml(content);

textView.setText(spanned);

问题是在textView 中我得到的是 HTML 标签,而不是应用换行符。

1. With the mixtures<br />2. Colors and others<br />3. Categories and people<br />4. Health and fitness

【问题讨论】:

    标签: android tags textview


    【解决方案1】:
    articles[0] = "1. With the mixtures&lt;<br />2. Colors and others&lt;<br />";
    // articles[1] = "3. Categories and people&lt;<br />4. Health and fitness";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-22
      • 2016-02-22
      • 2011-06-15
      • 1970-01-01
      • 2021-10-17
      • 2012-11-10
      相关资源
      最近更新 更多