views:

216

answers:

2

Why is this soo hard to find out?

public boolean onTouch(View v, MotionEvent event)

I need to convert float event.getY() to and int.

Is this possible.

event.getY().intValue() will not work at all.

Any ideas?

+4  A: 

Uhhh, yeah, how about:

int y = (int)event.getY();

You see getY() only returns a float for devices that have a sub-pixel accuracy.

CaseyB
It always returns a float. Maybe you mean the float represents an integer?
Matthew Flaschen
Correct. On devices that don't have sub-pixel accuracy the float is always something like 235.0. You can just cast to an int to get the pixel value.
CaseyB
Thanks this worked.
dweebsonduty
A: 

Just cast it:

int val = (int)event.getY();
Matthew Flaschen