Reputation: 1189
Can anyone help me to fix this error on getPointerCount()
, getX()
, and getY()
?
Multiple markers at this line
The method
getPointerCount()
is undefined for the typeMotionEvent
Code
int pointerIndex;
public boolean onTouchEvent(MotionEvent event)
{
float xPosition1 = 0;
float yPosition1 = 0;
float xPosition2 = 0;
float yPosition2 = 0;
for (pointerIndex = 0; pointerIndex < event.getPointerCount(); pointerIndex++) //Error
{
if (pointerIndex == 0)
{
xPosition1 = event.getX(pointerIndex);// Error
yPosition1 = event.getY(pointerIndex);//Error
}
if (pointerIndex == 1)
{
xPosition2 = event.getX(pointerIndex);//Error
yPosition2 = event.getX(pointerIndex);//Error
}
}
Upvotes: 2
Views: 587
Reputation: 8180
getPointerCount()
is available starting from API level 5. If you use any SDK older than Android 2.0, you'll get that error.
Upvotes: 3