Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 906651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:25:20+00:00 2026-05-15T16:25:20+00:00

I am using the Android onTouchEvent to register touch and the associated movement. I

  • 0

I am using the Android onTouchEvent to register touch and the associated movement. I then want to iterate a sprite along that path.

I need to store the path traced by the finger for use later on.

The problem is that after the finger is lifted off the screen the ArrayList (pArray) is completely populated with the X & Y position of the ACTION_UP coordinates.

From the Log i can see that it is adding the current X & Y position to the Arraylist while the finger is moving which is great but then the Arraylist gets overwritten by the data in Arraylist.size() – 1…

Can someone please offer a suggestion.

public boolean onTouchEvent(MotionEvent event) {

  synchronized (mHeartbeat.getSurfaceHolder()) {

    getXX = event.getX();
    getYY = event.getY();

    pathArr.setX(getXX);
    pathArr.setY(getYY);

    pArray.add(pathArr);

    if (event.getAction() == MotionEvent.ACTION_DOWN) {

    } else if(event.getAction() == MotionEvent.ACTION_MOVE) {

    } else if(event.getAction() == MotionEvent.ACTION_UP) {

    }

    return true;
   }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:25:21+00:00Added an answer on May 15, 2026 at 4:25 pm

    It’s because you are not creating new pathArr variables and are adding the same one to the array each time. It also appears to be an instance field. You need to change it to a local variable and create a new one for each event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Android opengl I need to move an object from point A to point
I am using android java to create an application that uses the accelerometer, i
I 'm using Android draw9path for an image that I will set for background.
I am using Android Timer for a game. I want to implement a countdown
I am using Android-C2DM, and when I receive a message that has been pushed
I am using android-c2dm, and my device successfully receives messages from it. I want
Using Android 2.1+. I have a service that gets killed from time to time
When I take pictures using android.hardware.camera and I save them to the following location
i am using android:imeOptions=actionSearch in editText and my question is can i write my
I am using Android SDK 1.6 and developing some simple apps. It seems everytime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.