1 package com.example.android.nativemididemo; 2 3 import android.content.Context; 4 import android.view.MotionEvent; 5 import android.util.AttributeSet; 6 import android.widget.ScrollView; 7 8 public class TouchableScrollView extends ScrollView { 9 public boolean isTouched; 10 11 public TouchableScrollView(Context context) { 12 super(context); 13 } 14 15 public TouchableScrollView(Context context, AttributeSet attrs) { 16 super(context, attrs); 17 } 18 19 @Override 20 public boolean onTouchEvent(MotionEvent event) { 21 switch (event.getAction()) { 22 case MotionEvent.ACTION_DOWN: 23 isTouched = true; 24 break; 25 case MotionEvent.ACTION_CANCEL: 26 case MotionEvent.ACTION_UP: 27 isTouched = false; 28 break; 29 } 30 return super.onTouchEvent(event); 31 } 32 } 33