【发布时间】:2015-04-20 04:39:12
【问题描述】:
所以,如果有人知道为什么这不起作用,我会发布给出错误的代码,让我知道,并给出解释。 (不要只是说这是一种不好的编码方式或其他东西)(或者至少如果你自己解释的话)。所以下面的代码应该是当某人点击的颜色为真时切换到另一个屏幕!
public boolean onTouch(View v, MotionEvent event) {
int x = (int) event.getX();
int y = (int) event.getY();
if(isInsideCircle(x, y) == true){
//Do your things here
if(redColor == lastColor){
// error is here Intent i = new Intent(this, YouFailed.class);
// and here Activity.startActivity(i);
} else {
addPoints++;
}
}else {
}
return true;
}
有两个错误:
构造函数Intent(DrawingView, Class<YouFailed>)未定义
和
无法从 Activity 类型对非静态方法 startActivity(Intent) 进行静态引用
【问题讨论】:
标签: java android ontouchlistener touch-event ontouch