previously i have added a ontouch listener to textviews which will do a custom vibration upon each touch.
however when i hold the textview it will keep playing out the custom vibration.
how do i set it so that it would only vibrate only once per touch even when i am holding on the textview
i tried onclick and a few other listeners but it doesn’t do what i want.. as i require the textview to do the vibration on touch as they go from 1 textview to another
public boolean onTouch(View v, MotionEvent event)
{
vibratePattern();
return true;
}
private void vibratePattern()
{
Vibrator vibrator;
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
int dot = 100;
int dash = 250;
int short_gap = 200;
int medium_gap = 500;
int long_gap = 1000;
long[] pattern101 = {
0,
dot, short_gap, dash, short_gap, dot,
long_gap
};
vibrator.vibrate(pattern101, -1);
}
It might be something in your
vibratePatternmethod, but this should work and vibrate only once if you check for correct action on the event:UPDATE:
If that won’t work with multiple views, then you could attach the same listener to all views and check when the
vreference changes: