2012-08-14 68 views
0

我使用LinearLayout来表示我的用户界面的不同部分。这个想法是,这些布局将在网格布局中。另外,用户将能够拖动窗口重新排列它们。我从创建我的布局开始,一切都很好。然后我施加OnTouchListener我的意见:Android LinearLayout Multi-Touch

touchListener = new View.OnTouchListener() { 
      @Override 
      public boolean onTouch(View v, MotionEvent event) { 
       Log.e("VARS","MotionEvent!"); 
       if(event.getPointerCount() == 2) { 
       Log.e("VARS","It's two!"); 

       } 
       return false; 
      } 
     }; 

它完全忽略的情况下event.getPointerCount()是二!看起来这个方法只在指针数为1时才被调用。我把这个在我的清单:

<uses-feature android:name="android.hardware.touchscreen.multitouch"/>

,它仍然无法正常工作。 LinearLayout有一个特殊情况,其中只有指针数为1的MotionEvent被识别,或者是否有其他东西丢失?

回答

1

您需要将return false更改为return true。通过消耗MotionEvent,它将正常工作。

+0

谢谢,这很好! – crocboy 2012-08-14 21:39:29