Fragment点击超链接跳转浏览器报错

来源:互联网 发布:linux运维工程师培训 编辑:程序博客网 时间:2024/04/28 04:29

Tweet item = getItem(position);
//设置可以点击超链接
Spanned spanned = Html.fromHtml(item.getBody( ));
holder.tvTweetContent.setText(spanned);
holder.tvTweetContent.setMovementMethod(LinkMovementMethod.getInstance( ));

设置可以点击的超链接后报错:
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.

原因是使用了getApplicationContext()
convertView = View.inflate(getActivity().getApplicationContext(), R.layout.list_item_tweet, null);
改为
convertView = View.inflate(getActivity(), R.layout.list_item_tweet, null);

0 0
原创粉丝点击