You will try this i hope it will work fine for your cases...
You just use this Activity and use this method for your implementation all the best...
You just use the below listener class for the implementation of long press only....
public class MainActivity extends Activity {
private Button button;
int check=0;
private GestureDetector detector;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.id.button1);
detector = new GestureDetector(new GestureListener());
check=0;
button.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
detector.onTouchEvent(event);
int action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_MOVE:
System.out.println("Move");
break;
case MotionEvent.ACTION_DOWN:
System.out.println("Down");
break;
case MotionEvent.ACTION_UP:
System.out.println("Released");
break;
default:
break;
}
return false;
}
});
}
class GestureListener implements OnGestureListener
{
@Override
public boolean onDown(MotionEvent e) {
System.out.println("Down List");
return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
System.out.println("Fly List");
return false;
}
@Override
public void onLongPress(MotionEvent e) {
System.out.println("Long press");
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
System.out.println("Press List");
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
System.out.println("Single Tap List");
return false;
}
}
}