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?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With