另一个Linkify问题

时间:2011-06-22 13:55:45

标签: android listview linkify

由于我是Android编程的新手,我无法想出一个链接到listview。

我的链接代码是:

TextView textviewlink = new TextView(this);
textviewlink.setText("text I want to see"); 

TransformFilter mentionFilter = new TransformFilter() { 
public final String transformUrl(final Matcher match, String url) { 
return new String("http://test.com/"); 
} 
}; 

Pattern pattern = Pattern.compile("."); 
String scheme = ""; 
Linkify.addLinks(textviewlink, pattern, scheme, null, mentionFilter); 

Now I want to place textviewlink into a HashMap:

ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); 
HashMap<String, String> map = new HashMap<String, String>();

所以我这样添加:

map.put("c1", "STATUTE");
map.put("c0", " ");
map.put("c2", textviewlink.toString()); 
mylist.add(map); 

然后:

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);   

但是当我显示它时,链接看起来像:

android.widget.textview@43e604c0

1 个答案:

答案 0 :(得分:0)

您想使用textviewlink.getText()而不是textviewlink.toString()

toString()只返回对象的字符串表示形式,与文本值不同。