Another Linkify question
since I am new to android programming I can't figure out to get a link into a listview.
My code to linkify is:
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>();
so I add like this:
map.put("c1", "STATUTE");
map.put("c0", " ");
map.put("c2", textviewlink.toString());
mylist.add(map);
and then:
ListView listnew = (ListView) findView开发者_JAVA技巧ById(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);
but when I display it the link looks like:
android.widget.textview@43e604c0
You want to use textviewlink.getText()
rather than textviewlink.toString()
toString()
simply returns a string representation of your object, which is not the same thing as its text value.
精彩评论