Problem when click to HTML links inside a ListView?
i used the code below for my listview and textview .
Code:
textcontent.setText(Html.fromHtml(item.get_text())开发者_高级运维);
textcontent.setAutoLinkMask(Linkify.WEB_URLS);
XML:
<TextView
android:id="@+id/txtview"
android:autoLink="web"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="put your link here"/>
the link looks like url and i can click it but it generate this exception
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.
any idea how to solve this problem ?
Don't pass application context to ListAdapter constructor. Pass your main activity instead.
ListAdapter flareAdapter = new ListAdapter(LayoutInflater.from(activity), Items);
Even if you create adapter in some other class you should pass main activity reference anyway.
Are you sure the click caused that exception not something you want to launch?
As I see you need to add the flags to the intent (not sure what is your intent though)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
精彩评论