Android :: OnTouchListener && OnClickListener combination issue

Problem description:

I have a TextView on a RelativeLayout and I want to color it red when the user touches it, and go on another page when he clicks on it. So I tried to set an OnClickListener to do the click, and an OnTouchListener to implement the touch function (MotionEvent.ACTION_DOWN) but this combination doesn't work, because OnTouchListener makes OnClickListener non-functional (don't know why).

On forums people say that we can implement the OnClick by the OnTouch MotionEvent.ACTION_UP, but this one can be triggered out of my TextView layout (the TextView gonna be clicked if you press it and drag your finger out of him to release) and this is not the desired behavior because I want:
click = press + release on the TextView.

Can someone give me a solution for this please?

5
задан Linus Kleen 12 December 2012 в 10:50
поделиться