问题
i am creating a listview. in that list each item has text view. and in text views i am defining linkify texts based on data from the web service..
now when i click on that linkify text i am getting error like
09-21 20:27:38.031: ERROR/AndroidRuntime(766): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=\"ticbeat.com/socialmedia/fa…" (has extras)
please help me solving this problem.. any answer with solution will highly appreciated.
Update:
Code:
if(urlentities[position]!=null && dpurlentities[position]!=null)
holder.twtdata.setText(Html.fromHtml(timelines[position].replace(urlentities[position],"<a href=\\\""+dpurlentities[position]+"\">"+urlentities[position]+"</a>")));
回答1:
Look like you need to put http://
at the beginning of that URL. Without the protocol specifier Android appears to assume "content://" is the intended url type.
回答2:
Linkify by default opens the default browser (new activity). I'm guessing you pass getBaseContext()
as context to the TextView(Context context)
. You have to pass the activity as Context for that to work by default. If you are concerned about memory leaks you can try getApplicationContext()
but haven't tested it.
The best way to handle that is to create a listener at the TextView fired on onclick()
of the span . Your activity (the one that created the textView() catches that listener and then the activity opens the browser. Here you can see how to make your own listener
Another way to do that is to implement a WebView in you layout and all you have to do from the textView is to show that webView with the link clicked. getBaseContext() can do that.
来源:https://stackoverflow.com/questions/7502306/dynamic-linkify-text-in-listview-error-no-intent-found-with-data-specified