I am developing an android application. In my application,I have one image view. I want to determine long press listener on image view,when I long press on image i want to vibrate device.How is possible? Thanks all
You can try to do it this way:
ImageView imageView = (ImageView) findViewById(R.id.ImageView);
final Vibrator vibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
imageView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
vibrator.vibrate(100);
return true;
}
});
you can try this
ImageView iv = (ImageView) findViewById(R.id.ImageView);
iv.setOnLongClickListener(vlong);
private View.OnLongClickListener vLong = new View.OnLongClickListener() {
public boolean onLongClick(View view) {
// do any thing
return true;
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With