Friday, July 5, 2013

[android help] Can't get x and y during drag and drop


Can't get x and y during drag and drop



For an App I am developing, I am implementing drag and drop. During the dragging process I want to get the current x and y position of the finger on screen as precise as possible. I have tried to use onTouchEvent as shown in the code below. However, this returns the x and y coordinates only when I am not dragging an object over the screen and it is also not precise enough. So my question is:


How do I get the current x and y coordinates when using drag and drop as precise as possible?




@Override
public boolean onTouchEvent(MotionEvent event) {
int x = (int) event.getX();
int y = (int) event.getY();

switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
Log.d("Checks", "x and y: " + x + ", " + y);
return true;
}
return true;
}


Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...