0
我知道这个问题已经被问及在StackOverflow这里回答..但我似乎无法让变量工作。有人建议我使用这个代码,但仍然没有去。简单的解释是我需要一个功能来在你的手指停在屏幕上时运行(显然不能在UI内完成)。因此,一个新的线程.. x,y,高度,宽度。将参数传递给线程
//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
}
的这个修改后的版本是什么得到它的工作..非常感谢你..我不是一个图形的人,所以我很少处理瓦特/线程。 – DJPlayer
没有问题的朋友......你是最受欢迎的。 :) –