关于在listview中加textview的autolink的问题

Textview添加了autolink后他会截获listview的item 点击事件 

package com.example.testtextviewlink;

import android.content.Context;
import android.text.Spannable;
import android.text.style.ClickableSpan;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.TextView;

/**
* @author Jason zhang
* @TODO
* @2012-11-20
*/
public class TextT extends TextView {

public TextT(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}

public TextT(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

public TextT(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
super.onTouchEvent(event);
ClickableSpan[] links = ((Spannable) this.getText()).getSpans(getSelectionStart(),
getSelectionEnd(), ClickableSpan.class);
if (links.length != 0) {
links[0].onClick(this);
return true;
}else{
return false;
}
}
}

posted @ 2012-11-20 18:12  天边的星星  阅读(1451)  评论(0编辑  收藏  举报