1
Longpressに電話をかけた後、スクロールイベントを呼び出すにはどうすればよいですか?(gesturedetectorを使用して)GestureDetectorを使用してLongpressを呼び出した後にスクロールイベントを呼び出す
public class TestingGestureDetector extends AppCompatActivity implements GestureDetector.OnGestureListener {
TextView mTextView;
private GestureDetector mGestureDetector;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testing_gesture_detector);
mTextView = (TextView) findViewById(R.id.gesture);
mTextView.setOnTouchListener(a());
mGestureDetector = new GestureDetector(this, this); //
}
protected View.OnTouchListener a() {
return new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
mGestureDetector.onTouchEvent(event); //
if (event.getAction() == MotionEvent.ACTION_UP)
mTextView.setText("Release");
return true;
}
};
}
@Override
public boolean onDown(MotionEvent event) {
mTextView.setText("Press");
return true;
}
@Override
public void onShowPress(MotionEvent event) {
}
@Override
public boolean onSingleTapUp(MotionEvent event) {
return true;
}
@Override
public boolean onScroll(MotionEvent event1, MotionEvent event2, float distanceX, float distanceY) {
mTextView.setText("Move");
return true;
}
@Override
public void onLongPress(MotionEvent event) {
mTextView.setText("Long Press");
//mGestureDetector.setIsLongpressEnabled(false);
}
@Override
public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {
return true;
}
}