I know this question has been asked and answered here on StackOverflow.. but I just can’t seem to get the variables to work. Someone advised me to use this code and still no go. The brief explanation is I need a function to run while your finger is down on the screen (Obviously can’t be done within the UI). Thus a new thread.. x,y,height,width.
//global variables
boolean var = false;
//instance variable to check if thread has started running for first time
int x, y, width, height;
// variables as instance variables
boolean fingerdown;
Thread myThread = new Thread()
{
@Override
public void run()
{
while(fingerdown==true);
{
// class object = new class() in the activity area
object.function(this.x ,this.y , this.height, this.width);
}
}
};
// this section is within the UI function that detections MotionEvents
if (event.getAction() == MotionEvent.ACTION_DOWN)
{
this.x = event.getX();
this.y = event.getY();
this.width = widthf;
this.height = heightf;
fingerdown = true;
if(!var)
{
var = true;
myThread.start();
}
}
if (event.getAction() == MotionEvent.ACTION_UP)
{
fingerdown = false
}
To call this thread use