The chances that your start and end location will be exactly the same are slim to none. If you want to do it all in a regular old onTouchEvent(), you'd want to have some sort or range... If down and up occur within some small range such as within 10 or something like that. Depending on what exactly you are trying to accomplish, you might be better off implementing OnGestureListener.
On Jul 10, 4:11 am, zeeshan <[email protected]> wrote: > Hi Dear, > > i need to have a left, right and click event in my App. > > i am trying it like below: > > @Override > public boolean onTouch(View v, MotionEvent event) { > > switch (event.getAction()) { > case MotionEvent.ACTION_DOWN: > > startX = (int)event.getX(); > > return true; > case MotionEvent.ACTION_UP: > endX = (int)event.getX(); > > if(startX == endX){ > // here i have > the click code > } > > else if(startX - endX >10 ){ // next page > > } > else if(endX - startX >10 ){ //back page > return true; > > } > > return super.onTouchEvent(event); > > } > > /////////////////////////////// > > left and right move works fine for me but the click doesn't work > soemtime. > > i tried a separate onClickListener along with onTouchListener but > onClickListener doesn't fire. > i believe to have click event in onTouch but the problem is that, > startX == endX comes true only on emulator not when we press finger on > real device. > > please suggest how can i capture click in touch event? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

