【发布时间】:2011-09-22 04:33:13
【问题描述】:
您好,我有一个问题,我似乎无法弄清楚。我正在尝试将 HTML 添加到作为 ListView 中的列的 textView。我有一个 3 列的 ListView 行。
我将 html 添加到 textView 的代码是:
TextView mTextSample = new TextView(this);
String text = "Visit my <a href='http://www.newblog.com'>blog</a>";
mTextSample.setText(Html.fromHtml(text));
然后我有一个 HashMap,我在其中也添加了 mTextSample.getText():
HashMap Object, Object map = new HashMap Object, Object();
map.put("c1", "STATUTE");
map.put("c0", "");
map.put("c2", mTextSample.getText());
mylist.add(map);
然后将这一行添加到我的 ListView 中(R.id.CELL2 应该有 html):
final ListView listnew = (ListView) findViewById(R.id.lvdata);
SimpleAdapter mSchedulenew = new SimpleAdapter(this, (List<? extends Map<String, ?>>) mylist, R.layout.row,
new String[] {"c1","c0","c2"}, new int[] {R.id.CELL1,R.id.CELLBlank, R.id.CELL2});
listnew.setAdapter(mSchedulenew);
但运行时只显示“访问我的博客”(这是正确的,但没有生成链接)。当我将此行添加到 listView 时,似乎 html 正在被过滤掉。
【问题讨论】:
标签: android html listview hyperlink