I am trying to develop a musical instrument app in android. I implemented OnTouchListener for every button, and there is no problem when I just touch one button. But when I touch a button and move my finger to the next one, the OnTouchListener for that button is not called and its sound not playing. How can I manage to play sounds during sliding my finger on the buttons without taking my finger up?
(I read many questions but they aren’t useful)
my simple OnTouchListener for each button:
final ImageButton img_1 = (ImageButton) findViewById(R.id.img_1);
img_1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if( event.getAction() == MotionEvent.ACTION_DOWN ) {
snd.play_s_l_1();
}
return true;
}
});
Check the MotionEvent.MOVE: