Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clickable Links inside listview

List view clickable link poblem.

I'm using the following code inside the getView() to generate a clickable link in a listview.

myTextView.setMovementMethod(LinkMovementMethod.getInstance());
String linkText = "<a href=\"http://www.google.com\">Google</a>";
myTextView.setText(Html.fromHtml(linkText));

This code works fine on a textview which is not in a listview but when i use it for a textview within a list view the following exception is raised on clicking the link.

AndroidRuntimeException: Calling startActivity() from outside of an Activity
context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
like image 282
Vikas Gulati Avatar asked Feb 21 '23 17:02

Vikas Gulati


1 Answers

Got the answer here. I just had to change the constructor call from

CustomAdapter mAdapter = new CustomAdapter( mContext, itemList);

to

CustomAdapter mAdapter = new CustomAdapter( this, itemList);
like image 120
Vikas Gulati Avatar answered Mar 07 '23 21:03

Vikas Gulati