2014-03-26 51 views
0

我在檢測觸摸事件期間遇到問題。它的工作正常,沒有滾動。但滾動完成後,當我刪除手指不能接收動作事件。我正在使用以下代碼。Android上滾動後未檢測到觸摸事件

linearMain.setOnTouchListener(new OnTouchListener() { 

      @Override 
      public boolean onTouch(View v, MotionEvent event) { 

       switch (event.getAction()) { 
       case MotionEvent.ACTION_DOWN: 
        // Do Something 
        Log.d("Touch", "Touch down"); 

        // Now Set your animation 
        slidingDrawerMos.startAnimation(slideOutAnimation); 
        slidingDrawerReviews.startAnimation(slideOutAnimation); 

        slidingDrawerMos.setVisibility(View.GONE); 
        slidingDrawerReviews.setVisibility(View.GONE); 

        break; 

       case MotionEvent.ACTION_MOVE: 
        // Do Something 
        Log.d("Touch", "Touch move"); 
        break; 

       case MotionEvent.ACTION_UP: 
        // Do Something 
        Log.d("Touch", "Touch up"); 
        slidingDrawerMos.setVisibility(View.VISIBLE); 
        slidingDrawerReviews.setVisibility(View.VISIBLE); 

        // Now Set your animation 
        slidingDrawerMos.startAnimation(slideInAnimation); 
        slidingDrawerReviews.startAnimation(slideInAnimation); 
        break; 

       case MotionEvent.ACTION_CANCEL: 
        Log.d("Touch", "Touch cancel"); 
        break; 
       default: 
        break; 
       } 

       return true; 
      } 
     }); 

回答

1
your_control.setMovementMethod(new ScrollingMovementMethod()); 

findViewById(R.id.your_control).getParent() 
          .requestDisallowInterceptTouchEvent(false); 
+0

謝謝您的答覆。我無法設置linear.setMovementMethod(新的ScrollingMovementMethod())。請幫幫我。 –

+0

確定它不適用於線性佈局..它適用於底層的小部件..你可以發佈xml嗎? – Android

+0

你需要哪個xml。它的正常xml。只是我找到線性佈局對象,然後將觸摸事件分配給它。 –