I have got this button which uses onclicklistener and onlongclicklistener, but also a button which uses ontouchlistener...
the point is button 1 is 0,1 second pressed, button 2 is 2 seconds pressed, button 3 could be pressed for 50 seconds or even more... but button 3 is seen as long click instead of touch on release after 5 seconds, and so it will not trigger my action
I used:
MainActivity extends Activity implements View.OnClickListener,
View.OnLongClickListener, View.OnTouchListener {
button1.setOnClickListener(this);
button2.setOnLongClickListener(this);
button3.setOnTouchListener(this);
public boolean onTouch(View v, MotionEvent event) {
switch (v.getId()) {
case R.id.button3:
if(event.getAction() == MotionEvent.ACTION_DOWN) {
DoTest1();
} else if (event.getAction() == MotionEvent.ACTION_UP) {
DoTest2();
}
break;
}
return false;
}
When I remove the onlongclicklistener it's working fine..
Any idea's?
Thanks for your support!!!
You could use View.setLongClickable(false)
on button 3.