textview-Android下,ListView下面的TextView包含超链接点击报错,求高人解决下,谢谢

问题描述

Android下,ListView下面的TextView包含超链接点击报错,求高人解决下,谢谢

Listview 下面的TextView包含了超链接,点击之后报错,
源码是:
TextView tv_1=(TextView) view.findViewById(R.id.txt_ask);

tv_1.setText(Html.fromHtml(str[position]));

tv_1.setMovementMethod(LinkMovementMethod.getInstance()); 

错误是:

06-15 13:03:47.648: E/InputEventReceiver(30313): Exception dispatching input event.

06-15 13:03:47.648: E/MessageQueue-JNI(30313): Exception in MessageQueue callback: handleReceiveCallback
06-15 13:03:47.655: E/MessageQueue-JNI(30313): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.app.ContextImpl.startActivity(ContextImpl.java:1055)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.app.ContextImpl.startActivity(ContextImpl.java:1042)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.content.ContextWrapper.startActivity(ContextWrapper.java:284)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.text.style.URLSpan.onClick(URLSpan.java:99)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:212)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.widget.TextView.onTouchEvent(TextView.java:7609)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.View.dispatchTouchEvent(View.java:7352)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2075)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1524)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.app.Activity.dispatchTouchEvent(Activity.java:2530)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.java:268)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2023)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.View.dispatchPointerEvent(View.java:7532)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3682)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3610)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4862)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4822)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4974)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.os.MessageQueue.nativePollOnce(Native Method)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.os.MessageQueue.next(MessageQueue.java:125)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.os.Looper.loop(Looper.java:140)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at android.app.ActivityThread.main(ActivityThread.java:5383)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at java.lang.reflect.Method.invokeNative(Native Method)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at java.lang.reflect.Method.invoke(Method.java:511)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
06-15 13:03:47.655: E/MessageQueue-JNI(30313): at dalvik.system.NativeStart.main(Native Method)
06-15 13:03:47.660: E/AndroidRuntime(30313): FATAL EXCEPTION: main
06-15 13:03:47.660: E/AndroidRuntime(30313): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.app.ContextImpl.startActivity(ContextImpl.java:1055)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.app.ContextImpl.startActivity(ContextImpl.java:1042)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.content.ContextWrapper.startActivity(ContextWrapper.java:284)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.text.style.URLSpan.onClick(URLSpan.java:99)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:212)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.widget.TextView.onTouchEvent(TextView.java:7609)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.View.dispatchTouchEvent(View.java:7352)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063)
06-15 13:03:47.660: E/AndroidRuntime(30313): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358)

解决方案

看下MessageQueue callback: handleReceiveCallback 这个方法,它出错了

解决方案二:

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

看到这句话没?

你点击跳转的时候intent加上FLAG_ACTIVITY_NEW_TASK 这个flag。

解决方案三:

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

这句话不是告诉你了吗? intent跳转的时候开个任务。

解决方案四:

<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >

<TextView
    android:id="@+id/tv_website"
    android:layout_width="wrap_content"
    android:autoLink="web"
    android:layout_height="wrap_content"/>
 public class ListViewActivity extends ActionBarActivity {

    private ListView listView;
    private List<String> list=new ArrayList<String>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_list_view);
        listView=(ListView)findViewById(R.id.listview);
        initData();
        listView.setAdapter(new MyAdapter());
    }
    private void initData(){
        list.add("http://www.hao123.com");
        list.add("http://www.sina.com");
    }
    private class MyAdapter extends BaseAdapter{
        @Override
        public int getCount() {
            return list.size();
        }
        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return list.get(position);
        }
        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView textView=null;
            if(convertView==null){
                convertView=getLayoutInflater().inflate(R.layout.list_item, parent, false);
                textView=(TextView) convertView.findViewById(R.id.tv_website);
            }
            //textView.setText(getItem(position).toString());
            textView.setText(Html.fromHtml(getItem(position).toString()));
            return convertView;
        }

    }
}
时间: 2024-10-31 18:13:08

textview-Android下,ListView下面的TextView包含超链接点击报错,求高人解决下,谢谢的相关文章

java poi word-这个poi把String写入word文档后,打开文档就报“打开文件错误”,求高人解决下

问题描述 这个poi把String写入word文档后,打开文档就报"打开文件错误",求高人解决下 import java.io.ByteArrayInputStream;import java.io.FileOutputStream;import java.io.IOException; import org.apache.poi.poifs.filesystem.DirectoryEntry;import org.apache.poi.poifs.filesystem.Documen

javaee hibernate-求助avaee hibernate 项目控制台报错 求帮忙分析下,万分感谢!!

问题描述 求助avaee hibernate 项目控制台报错 求帮忙分析下,万分感谢!! 出现异常时间: [2013年8月9日 15:15:32] org.hibernate.HibernateException: Already disconnectedat com.hiaward.common.util.HibernateUtil.rollbackTransaction(HibernateUtil.java:175) at com.hiaward.common.util.HibernateU

ase ctivity-BaseActivity下自定义actionbar中的button设置点击事件无效,代码见下。

问题描述 BaseActivity下自定义actionbar中的button设置点击事件无效,代码见下. package com.lyri.main.base; import com.example.LlsqPs.R; import android.app.ActionBar;import android.app.Activity;import android.app.ActionBar.LayoutParams;import android.content.Context;import and

Android 获取listview数据 然后赋值给popupwindow用于显示报空指针

问题描述 Android 获取listview数据 然后赋值给popupwindow用于显示报空指针 能得到数据但是给Textview赋值却报空指针! 下边贴代码. gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // WindowManager.La

json校验格式报错,帮忙看下。

问题描述 json校验格式报错,帮忙看下. { "deplist": [ { bumen: 95, bound_id: "餐饮部", pad_sbound: "甜品类", pad_tab: 1 }, { bumen: 96, bound_id: "餐饮部", pad_sbound: "饮料类", pad_tab: 2 } ] } err info: bumen: 95, ------------------

textview-Android开发动态TextView问题报错求解答

问题描述 Android开发动态TextView问题报错求解答 两个画图界面,我想在第一个界面上加入一个TextView动态显示当前整点温度数据的数值 下面这个是XML文件控件声明 下面是我画折线的类 计算textview高度">下面是我在这个类下面写的setText![然后安装后画曲线的界面就不动了,控件也不显示文本,最后强制退出,下面是报错内容 我想问这里为什么会出错,我要实现这个功能要怎么办才可以!!我猜出错的原因是不是不能在这个类下面写setText()方法啊?求解答 解决方案 S

linux下php添加mysqli拓展库时,编译报错

问题描述 linux下php添加mysqli拓展库时,编译报错 php和mysql都是已经编译安装好了,现在想要给php添加mysqli 拓展库,结果在make的时候报错 cd /usr/local/src/php-5.6.19/ext/mysqli /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/local/mysql/bin/mys

eclipse-bubbo消费端在工具中启动报错打包后tomcat下正常

问题描述 bubbo消费端在工具中启动报错打包后tomcat下正常 2016-04-04 15:12:03,845 ERROR [ContextLoader.java:336] : Context initialization failed java.lang.NoClassDefFoundError: Lvaolon/facade/user/service/UserFacade; at java.lang.Class.getDeclaredFields0(Native Method) at j

javase-Java连接derby报错,求大神帮解决下~

问题描述 Java连接derby报错,求大神帮解决下~ 解决方案 http://tieba.baidu.com/p/1415330675 用SYS登录时不可以进行建表操作,看样子derby的确有权限控制存在.哼哼哼哼--- 另,用户名中不能存在字符,刚才在用户名中包含了一个;号,结果出现了 错误 58009:网络协议异常:在 DSS 链中的下一个 DSS 段与当前段具有相同的标识号.连接已终止.错误 08004:发生连接认证失败.原因:用户无权访问数据库. 这样的错误 解决方案二: http:/