Triggering event when Button is pressed down in Android
You should do this: b is the button.
b.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN ) {
mSoundManager.playSound(2);
return true;
}
return false;
}
});
Maybe using a OnTouchListener
? I guess MotionEvent will have some methods for registering a touch on the object.
button.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
return false;
}
}))
import android.view.MotionEvent;