0
private String TAG = GestureActivity.class.getSimpleName();

float initialX, initialY;

@Override
public boolean onTouchEvent(MotionEvent event) {
    //mGestureDetector.onTouchEvent(event);

    int action = event.getActionMasked();

    switch (action) {

        case MotionEvent.ACTION_DOWN:
            initialX = event.getX();
            initialY = event.getY();
            AllocationAdapter imageView = null;

            imageView.setX((int) initialX);

            imageView.setY((int) initialY);

            Log.d(TAG, "Action was DOWN");
            break;
    }

    return super.onTouchEvent(event);
}

I am receiving errors at this point.

Madness
  • 2,730
  • 3
  • 20
  • 29

2 Answers2

0

Your object imageView is null, so you can't use imageView.setX() or imageView.setY().

You need to create one with the method :

  • AllocationAdapter create1D (RenderScript rs, Allocation a)
  • AllocationAdapter create2D (RenderScript rs, Allocation a)
  • AllocationAdapter createTyped (RenderScript rs, Allocation a, Type t)
  • Are you a bit more about that you can give the site name – Büşra Andaş Aug 26 '15 at 07:26
  • I get that from [here](http://developer.android.com/intl/ja/reference/android/renderscript/AllocationAdapter.html) but it's seem to be an advanced concept. Maybe it's not what you really want. Can you explain what is the use of the touch ? – Aurélien Guelle Aug 26 '15 at 07:34
  • Touching the object will go in that direction finger – Büşra Andaş Aug 26 '15 at 07:40
  • I'm guessing it's an imageView you are trying to move. [Maybe look here for what you want.](http://stackoverflow.com/questions/16557076/how-to-smoothly-move-a-image-view-with-users-finger-on-android-emulator) – Aurélien Guelle Aug 26 '15 at 07:50
0

Error occurred in this line

imageView.setX((int) initialX);

because your trying to set value for null object

Initialize the imageView

uday
  • 1,348
  • 12
  • 27