There is a question for "How to enable vibration on an ImageView
, this question is how to do the same thing with a toggle button
.
Current implementation (haptic feedback only on certain devices):
toggleBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (zero) {
setOne();
myVib.vibrate(5);
} else {
setZero();
myVib.vibrate(5);
}
}
});