I have a functional code but after last SDK update I'm getting this warning:
Multiple markers at this line
- onTouch should call View#performClick when a click is detected
- implements android.view.View.OnTouchListener.onTouch
med.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
detect.setEnabled(false);
}
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
detect.setEnabled(true);
}
//v.performClick();
Log.e("next", "touch");
return false;
}
});
med.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(!center) {
send("1");
} else {
send("2");
}
Vibrate(100);
Log.e("next","click");
}
});
My code is working properly but if I uncoment v.performClick(); to remove warning I get unwanted behaviour. Why am I getting this warning and is there going to be some problems if I discard it and leave the code as is?
EDIT:
this is my log when I click on button:
"next", "touch"
"next", "touch"
"next", "click"
and this is with v.performClick()
"next", "click"
"next", "touch"
"next", "click"
"next", "touch"
"next", "click"
You should put the
v.performClick();
inside the second if:
if (event.getAction() == MotionEvent.ACTION_UP ....) {
v.performClick();
detect.setEnabled(false);
}
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