TextView
我有一个ArrayAdapter
可能包含一些超链接的内容。对于我使用的那些链接Linkify
:
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (rowView == null) {
rowView = inflater.inflate(R.layout.list_item_2, null);
holder = new ViewHolder();
holder.content = (TextView) rowView.findViewById(R.id.postContent);
holder.date = (TextView) rowView.findViewById(R.id.postDate);
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
holder.content.setText(contents.get(position));
holder.date.setText(dates.get(position));
Linkify.addLinks(holder.content, Linkify.ALL);
return rowView;
}
但是因为Linkify
在 ArrayAdapter 中添加了 ,所以我得到一个异常说:
08-05 16:42:16.715: E/AndroidRuntime(20598): FATAL EXCEPTION: main
08-05 16:42:16.715: E/AndroidRuntime(20598): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
08-05 16:42:16.715: E/AndroidRuntime(20598): at android.app.ContextImpl.startActivity(ContextImpl.java:921)
08-05 16:42:16.715: E/AndroidRuntime(20598): at android.content.ContextWrapper.startActivity(ContextWrapper.java:283)
08-05 16:42:16.715: E/AndroidRuntime(20598): at android.text.style.URLSpan.onClick(URLSpan.java:62)
我怎样才能使这项工作?我想不出替代方案。