2

我有一个自定义TableLayout的代码:

public class PageTableLayout extends TableLayout{

private static Context context;
private GestureDetector gDetector;

public PageTableLayout(Context context) {
    super(context);
    this.context = context;
    gDetector = new GestureDetector(context, gesture_listner);
}

public PageTableLayout( Context context, AttributeSet attrs ){
    super( context, attrs );
    this.context = context;
    gDetector = new GestureDetector(context , gesture_listner);
}

@Override
public boolean dispatchTouchEvent(MotionEvent me) {
    Log(debug, "dispatchTouchEvent()");
    super.dispatchTouchEvent(me); 
    return gDetector.onTouchEvent(me);
}

private OnGestureListener gesture_listner = new OnGestureListener(){
    public boolean onDown(MotionEvent e) {
        // TODO Auto-generated method stub
        Log(debug, "onDown()..." );
        return false;
    }

    public boolean onFling(MotionEvent start, MotionEvent finish, float velocityX, float velocityY) {
        Log.(debug, "onFling()..." );
        .....
    }

    ...

 }

使用此代码,我无法检测到该onFling事件(它没有被调用!!!)..有什么建议吗?如果我把它OnGestureListener放在一个Activity它的工作原理!TableLayout包含包含的简单TableRow元素TextView。请帮我..

4

0 回答 0