Ontouch event of OnTouchListener gets called twice in android
Or just use onClickListener:
myButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
//do what you gotta do
}
});
touchListener will be called for every MotionEvent.ACTION_DOWN
, MotionEvent.ACTION_UP
, and MotionEvent.ACTION_MOVE
. so if you want to execute code only once , ie MotionEvent.ACTION_DOWN
then inside
onTouch()
if (event.getAction() == MotionEvent.ACTION_DOWN) {
//your code
}