如何调用android的drawLine()

时间:2014-12-04 16:55:58

标签: java android

基于此应用:https://github.com/valerio-bozzolan/AcrylicPaint/blob/master/src/anupam/acrylic/EasyPaint.java

我想在菜单中添加另一个项目,即绘制一条线。我是android的新手,所以请不要评价我:)这是我的尝试:

public boolean onTouch(View v, MotionEvent event) {
             float downx = 0, downy = 0, upx = 0, upy = 0;
            int action = event.getAction();
            switch (action) {
            case MotionEvent.ACTION_DOWN:
              downx = event.getX();
              downy = event.getY();
              break;
            case MotionEvent.ACTION_MOVE:
              break;
            case MotionEvent.ACTION_UP:
              upx = event.getX();
              upy = event.getY();
              mCanvas.drawLine(downx, downy, upx, upy, mPaint);  //<---
              invalidate();
              break;
            case MotionEvent.ACTION_CANCEL:
              break;
            default:
              break;
            }
            return true;
          }

然后我在onOptionsItemSelected(第314行)中添加这些行

    @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {

            case R.id.LINE_ID:
//i need to call it here        
                return true;
谢谢!!

0 个答案:

没有答案