Dynamic Linkify Text in ListView - Error : no intent found with data : specified url

雨燕双飞 提交于 2019-12-12 11:43:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!