package com.sai.touch;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.widget.Toast;
public class TouchActivity extends Activity implements OnGestureListener {
private GestureDetector gestureDetector;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gestureDetector = new GestureDetector(this);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
@Override
public boolean onDown(MotionEvent e) {
Toast.makeText(this,"oNDown called",Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
Toast.makeText(this,"oNFling called",Toast.LENGTH_SHORT).show();
return false;
}
@Override
public void onLongPress(MotionEvent e) {
Toast.makeText(this,"OnLongPress called",Toast.LENGTH_SHORT).show();
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
Toast.makeText(this,"onScroll called",Toast.LENGTH_SHORT).show();
return false;
}
@Override
public void onShowPress(MotionEvent e) {
Toast.makeText(this,"onShowPress called",Toast.LENGTH_SHORT).show();
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
Toast.makeText(this,"oNsingleTap called",Toast.LENGTH_SHORT).show();
return false;
}
}
No comments:
Post a Comment