不可转换类型,无法将“ com.example.apex.myapplication.shape”转换为“ com.example.apex.myapplication.circle”

时间:2018-12-27 06:11:16

标签: android android-canvas paint

我正在创建绘画应用程序,并且使用了Drawingcanvas类。与该类一起,我还使用了Shape类(circle, oval, rectangle and input text etc)。我的问题是,当我在DrawingCanvas类的if语句中使用所有形状时,每次都将一个错误(不可转换类型,无法强制转换"com.example.apex.myapplication.shape")到circle.oval,InputText等上。

case MotionEvent.ACTION_MOVE:
                if (mCurrentOperation == Constants.OPERATION_DRAW_PENCIL || mCurrentOperation == Constants.OPERATION_ERASE) {
                    mBrushPath.lineTo(xPos, yPos);
                } else if (mCurrentOperation == Constants.OPERATION_MOVE_VIEW)

                {
                    if (mCanvasLeftBounds < xPos && xPos < mCanvasRightBounds && mCanvasTopBounds < yPos && yPos < mCanvasBottomBounds)

                    {

                        if (mShapeToMove instanceof Circle)
                        {
                            ((Circle) mShapeToMove)
                            ((Circle) mShapeToMove).setCenterX(xPos);
                            ((Circle) mShapeToMove).setCenterY(yPos);

0 个答案:

没有答案