内部列表视图可点击的链接 [英] Clickable Links inside listview

查看:128
本文介绍了内部列表视图可点击的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

列表视图可点击的链接poblem。

我用下面的code中的getView()里面生成一个列表视图可点击的链接。

  myTextView.setMovementMethod(LinkMovementMethod.getInstance());
串linktext的=&其中; A HREF = \的http://www.google.com \>谷歌&所述; / A>中;
myTextView.setText(Html.fromHtml(linktext的));
 

这code正常工作的一个TextView这是不是在ListView但是当我使用它的一个TextView在列表查看以下异常引发上点击链接。

  AndroidRuntimeException:从活动之外调用startActivity()
上下文需要FLAG_ACTIVITY_NEW_TASK标志。这真的是你想要的吗?
 

解决方案

这里得到的答案 。我不得不改从构造函数调用

  CustomAdapter mAdapter =新CustomAdapter(mContext,ITEMLIST);
 

  CustomAdapter mAdapter =新CustomAdapter(这一点,ITEMLIST);
 

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);

这篇关于内部列表视图可点击的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆