基于此应用: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;
谢谢!!