解决方案 »

  1.   

    自己实现ontouchListener不就行了
      

  2.   

    我觉得你可以思考一下一下2个问题:
         (1)是不是非的监听整个popwindow窗口的手势,如果监听里面某一个控件的手势行不行?
         (2)为什么要让popwindow窗体来继承 OnGestureListener,为什么不直接新建一个手势类,然后让popwindows窗体来绑定这个类。我给你2种解决方案:
    (1)根据你的描述,假定你如果得到了onTouchEvent的事件就可以解决这个问题,所以我给出的第一个解决方案是:implements OnTouchListener, OnGestureListener多继承一个OnTouchListener事件,里面自动继承一个onTouch事件,该事件和你刚纔所说的onTouchEvent等价。
    (2)第二种方法,有点取巧,假设你的popwindow的布局文件类似如下:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
         android:id="@+id/poplayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
     ......
    </RelativeLayout>新建一个类叫做MyGestureListener.java,代码如下:
    class MyGestureListener implements OnTouchListener, OnGestureListener { @Override
    public boolean onDown(MotionEvent e) {
    // TODO Auto-generated method stub
    return false;
    } @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
    float velocityY) {
    return false;
    } @Override
    public void onLongPress(MotionEvent e) {
    // TODO Auto-generated method stub } @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2,
    float distanceX, float distanceY) {
    return false;
    } @Override
    public void onShowPress(MotionEvent e) {
    // TODO Auto-generated method stub } @Override
    public boolean onSingleTapUp(MotionEvent e) {
    // TODO Auto-generated method stub
    return false;
    } @Override
    public boolean onTouch(View v, MotionEvent event) {
    gesture_detector.onTouchEvent(event);
    return false;
    } }
    在对应的函数中调用:
    RelativeLayout poplayout=poplayout=(RelativeLayout)findViewById(R.id.pop);
    poplayout.setOnTouchListener(new MyGestureListener());这样一来就能实现手势调用了,在MyGestureListener类中该干嘛干嘛。