Triggering event when Button is pressed down in Android
Posted
by Cody
on Stack Overflow
See other posts from Stack Overflow
or by Cody
Published on 2010-04-11T00:42:34Z
Indexed on
2010/04/11
0:53 UTC
Read the original article
Hit count: 368
I have the following code for Android which works fine to play a sound once a button is clicked: Button SoundButton2 = (Button)findViewById(R.id.sound2); SoundButton2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(2);
}
});
My problem is that I want the sound to play immediately upon pressing the button (touch down), not when it is released (touch up). Any ideas on how I can accomplish this?
© Stack Overflow or respective owner