在Android层实现触摸屏校验
2010-05-31 14:35:00 来源:WEB开发网cal.get_sample(direction, (int)event.getX(), (int)event.getY(),
xList[direction], yList[direction]);
Log.i("XXW", "calibrate_main");
cal.calibrate_main();
Toast.makeText(getBaseContext(), "Calibrate Done!", Toast.LENGTH_SHORT).show();
SystemProperties.set("ts.config.calibrate", "done");
AndroidCalibrate.this.finish();
}
direction++;
return false;
}
});
}
public class CrossView extends View {
public CrossView(Context context) {
super(context);
}
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.GREEN);
if (direction == 0) {
canvas.drawLine(40, 50, 60, 50, paint);
canvas.drawLine(50, 40, 50, 60, paint);
paint.setColor(Color.WHITE);
} else if (direction == 1) {
canvas.drawLine(UI_SCREEN_WIDTH - 60, 50, UI_SCREEN_WIDTH - 40, 50, paint);
canvas.drawLine(UI_SCREEN_WIDTH - 50, 40, UI_SCREEN_WIDTH - 50, 60, paint);
paint.setColor(Color.WHITE);
} else if (direction == 2) {
canvas.drawLine(UI_SCREEN_WIDTH - 60, UI_SCREEN_HEIGHT - 50, UI_SCREEN_WIDTH - 40,
UI_SCREEN_HEIGHT - 50, paint);
canvas.drawLine(UI_SCREEN_WIDTH - 50, UI_SCREEN_HEIGHT - 60, UI_SCREEN_WIDTH - 50,
UI_SCREEN_HEIGHT - 40, paint);
paint.setColor(Color.WHITE);
} else if (direction == 3) {
canvas.drawLine(40, UI_SCREEN_HEIGHT - 50, 60, UI_SCREEN_HEIGHT - 50, paint);
canvas.drawLine(50, UI_SCREEN_HEIGHT - 60, 50, UI_SCREEN_HEIGHT - 40, paint);
paint.setColor(Color.WHITE);
} else if (direction == 4) {
canvas.drawLine(UI_SCREEN_WIDTH / 2 - 10, UI_SCREEN_HEIGHT / 2,
UI_SCREEN_WIDTH / 2 + 10, UI_SCREEN_HEIGHT / 2, paint);
更多精彩
赞助商链接