i making app needs detect clicks(i used onsingletapup
this)and holds(i used onshowpress
). problem click make registered hold first, , click. there way work around this?
p.s not looking long click not using onlongclicklistener
p.s.s i've tried using onclicklistener
for click , simpleongesturelistener
hold gesture isn't detected
relevant code
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.ground); gl = new gesturedetector(this,new mygl()); } class mygl extends gesturedetector.simpleongesturelistener { @override public boolean ondown(motionevent event) { return true; } @override public boolean onsingletapup(motionevent event) { log.i("motion","single"); return true; } @override public void onshowpress(motionevent e){ log.i("motion","long"); } } @override public boolean ontouchevent(motionevent e) { return gl.ontouchevent(e); }
i hoping see "single" logged "long" logged first , "single". 2 gestures detected within one.
kind of sounds api not intended used directly (without constraints) onsingletapup vs ondown . should consider reading documentation @ https://developer.android.com/reference/android/view/gesturedetector.simpleongesturelistener.html#ondown(android.view.motionevent) says:
this triggered every down event
you need filter out according specifications. reading documentation explain why.
perhaps should consider handling touchevent , filter touch logic you're looking for.
Comments
Post a Comment