我有一个基于本教程的项目,其中用户旋转轮子并且数字的值int days
根据轮子的当前位置发生变化,现在我想ImageView circle
根据这个数字的值显示或隐藏另一个图像,但是它抛出NullPointerException
这是我的onTouch
活动,对不起我的英语不好
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// reset the touched quadrants
for (int i = 0; i < quadrantTouched.length; i++) {
quadrantTouched[i] = false;
}
allowRotating = false;
startAngle = getAngle(event.getX(), event.getY());
break;
case MotionEvent.ACTION_MOVE:
double currentAngle = getAngle(event.getX(), event.getY());
rotateDialer((float) (startAngle - currentAngle));
startAngle = currentAngle;
days = ((int) currentAngle / 12) + 1;
String test = Integer.toString(days);
tvnumber.setText(test);
switch (days) {
case 1:
circle.setVisibility(View.INVISIBLE);
break;
case 3:
circle.setVisibility(View.VISIBLE);
break;
}
break;
case MotionEvent.ACTION_UP:
allowRotating = false;
break;
}
}
我的日志猫