Note that there are some explanatory texts on larger screens.

plurals
  1. POWhich Android Events do I use for this task?
    primarykey
    data
    text
    <p>I have a Java class that pertains to mouse listeners that I'm wanting to convert over to my Android app but can't quite find the necessary events.</p> <p>My Java app makes use of the following methods:</p> <ul> <li>mouseClicked</li> <li>mousePressed</li> <li>mouseReleased</li> </ul> <p>I'm wanting to do something similar however not with click events but touch events. I have come across <code>OnTouchListener</code> and did an override on the <code>onTouch</code> method.</p> <p>What are the alternatives to <code>mousePressed</code> and <code>mouseReleased</code>? <br> <br><br></p> <p><strong>Edit - (updated after Peter's response)</strong> </p> <p>Are the following events correct:</p> <ul> <li>ACTION_DOWN : mouseClicked</li> <li>ACTION_MOVE : mousePressed</li> <li>ACTION_UP : mouseReleased </li> </ul> <p><strong>EDIT - 2 Example Source</strong></p> <p>My Activity doesn't have any <code>OnTouchListener</code> at the moment because I was hoping I could keep all the touch logic in my View. </p> <p>View:</p> <pre><code>/*Inside my View - Is it proper to do onTouch logic here? Or should I be doing this from the Activity?*/ public class myView { public boolean onTouch(MotionEvent event) { switch(event.getAction() &amp; MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: //draw arrow when screen is simply touched break; case MotionEvent.ACTION_MOVE: //Do Logic break; case MotionEvent.ACTION_UP: //Do Logic break; } } } </code></pre> <p>The reason I am doing the logic in my View is because I have some variables that I would like to grab directly rather than creating multiple extra get methods. </p> <p>Am I able to do it like this? Or will I have to override the onTouch method in my Activity and do the logic there?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload