我有一个圆圈的代码显示onTouchListener
并在屏幕上用手指按住。现在我正在努力让手指从屏幕上取下时消失。我很确定ACTION_UP:
是我需要的。我只是不知道如何实现它。
这是我想要进入ACTION_UP
paint.setARGB(1, r, g, b);
到目前为止,这是相关代码:
public void onDraw(Canvas canvas)
{
paint.setARGB(255, r, g, b);
//drawing the circle
canvas.drawCircle(x,y,radius,paint);
}
public boolean onTouch(View view,MotionEvent event)
{
x=(int)event.getX()-(radius/2); //logic to plot the circle in exact touch place
y=(int)event.getY()-(radius/2);
//System.out.println("X,Y:"+"x"+","+y);
randColor(); //color of circle
invalidate();
return true;
//where I think I need to put ACTION_UP...
}
答案 0 :(得分:1)
它的工作原理如下:
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
Your code...
}
return false;
}