onTouchEvent onClick onLongClick calls
<p>In our application we handle the events in button to record data.</p>

<p>So initially when i use <code>setOnLongClickListener()</code> and <code>setOnClickListener()</code> together with the same button, it work fine for us.</p>

<p>That means it will call both this listener base on the click and LongClick of the button. Now when i tried to use <code>setOnTouchListener()</code> with the same button together with <code>setOnLongClickListener()</code> and <code>setOnClickListener()</code> then only OnTouch event is working, rest onclick and onLongclick event doesnt work.</p>

<p>Can anyone tell me why this happen and if possible explain me with an example.</p>

<p>The code i use is..</p>

<pre><code>Button btnAdd=new Button(this)

btnAdd.setOnLongClickListener(this);

btnAdd.setOnClickListener(this);

btnAdd.setOnTouchClickListener(this);

public void onClick(View v)
{
    //Statements;
}

public void onLongClick(View v)
{
    //Statements;
}

public boolean onTouch(View v, MotionEvent e) 
{
    switch (e.getAction())
    {
        case MotionEvent.ACTION_DOWN:
        {
            //store the X value when the user's finger was pressed down
            m_downXValue = e.getX();
            break;
        }   

        case MotionEvent.ACTION_UP:
        {
            //Get the X value when the user released his/her finger
            float currentX = e.getX();              
            //MotionEvent x=MotionEvent.obtain((long) m_downXValue,  SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 1, 1, 1, 1,0, 0, 0, 0, 0);

            // going forwards: pushing stuff to the left
            if (m_downXValue &gt; currentX &amp;&amp; currentX &lt; 0)
            {                   
                ViewFlipper vf = (ViewFlipper) findViewById(R.id.flipview);
                vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));


                vf.showNext();

            }

            // going backwards: pushing stuff to the right
            if (m_downXValue &lt; currentX &amp;&amp; currentX &gt; 100)
            {                   
                ViewFlipper vf = (ViewFlipper) findViewById(R.id.flipview);                                     
                vf.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));


                vf.showPrevious();

            }   

            if (m_downXValue == currentX)
            {                   
                onClick(v);
            }    

            break;
        }
    }
    return true;
}
</code></pre>
