2013-01-02 19 views
0

捕獲我的佈局是這樣 -Android的 - 多點觸控 - ACTION_POINTER_DOWN不能的onClick後查看

 <RelativeLayout 
     android:id="@+id/relativeLayoutTable" 
     android:layout_height="fill_parent"  
     android:layout_width="fill_parent"  
     android:layout_below="@+id/relativeLayout215" 
     android:layout_toRightOf="@+id/relativeLayout20" > 

      <ScrollView 
       android:id="@+id/scrollView" 
       android:layout_height="fill_parent"  
       android:layout_width="fill_parent"   
       android:scrollbars="horizontal|vertical" 
       android:fillViewport="true" 
       android:scrollbarStyle="insideOverlay"> 

       <HorizontalScrollView 
        android:id="@+id/horizontalScrollView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:scrollbarStyle="insideOverlay" > 

        <TableLayout 
         android:id="@+id/tableLayout1" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:gravity="center" /> 
       </HorizontalScrollView> 
     </ScrollView> 
    </RelativeLayout> 

的tablelayout由編程產生的細胞/觀。我已經爲每個單元格/視圖定義了onClicklistener。現在,我還爲scrollView定義了onTouchlistener。我可以獲取單元格/視圖的單擊事件,但是我沒有在scrollView中看到ACTION_POINTER_DOWN事件。請幫忙。謝謝。

回答

0

如果刪除onClicklistener,然後拖動/ onTouchlistener表格的佈局是確定 你可以嘗試的代碼,它爲我工作:

@Override 
public boolean onInterceptTouchEvent(MotionEvent event) { 
    boolean intercept = false; 
    switch (event.getAction() & MotionEvent.ACTION_MASK) { 
     case MotionEvent.ACTION_DOWN: { 
      currentX = (int) event.getRawX(); 
      currentY = (int) event.getRawY(); 
      break; 
     } 
     case MotionEvent.ACTION_MOVE: { 
      int x2 = Math.abs(currentX - (int) event.getRawX()); 
      int y2 = Math.abs(currentY - (int) event.getRawY()); 
      if (x2 > touchSlop || y2 > touchSlop) { 
       intercept = true; 
      } 
      break; 
     } 
     case MotionEvent.ACTION_POINTER_DOWN: {//it's important 
      oldDist = spacing(event); 
      mode = ZOOM; 
      intercept = true; 
      break; 
     } 
    } 
    return intercept; 
}