我想制作一个简单的涂鸦应用程序,用于
android,但我不知道如何从android获取一些数据!我需要:
拖动前后鼠标的位置或者如果是简单的触摸如何获得触摸的位置.
我应该怎么去画画
行呢?
有人能帮帮我吗?
解决方法
您可以在视图中覆盖onTouchEvent方法:
@Override public boolean onTouchEvent (MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { start_x = event.getX(); start_y = event.getY(); } else if (event.getAction() == MotionEvent.ACTION_MOVE) { //create the line from start_x and start_y to the current location //don't forget to invalidate the View otherwise your line won't get redrawn } else if (event.getAction() == MotionEvent.ACTION_UP) { //might not need anything here } return true; }