سؤال

My application has a minimum API level set to 10 and the main activity extends SherlockActivity which is basically a regular activity. I wanted to use the touch event, so I used this code:

@Override
  public boolean onTouchEvent(MotionEvent event) {
    try
    {
      float x1 = event.getAxisValue(MotionEvent.AXIS_X);

However, an exception was thrown:

java.lang.NoSuchMethodError: android.view.MotionEvent.getAxisValue

According to this, getAxisValue was added at API level 1. Why can't I use it?

هل كانت مفيدة؟

المحلول

getAxisValue (int axis) is added in api level 12.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top