after add "drawPath myline" why my apk crashed when i run it

0

After adding mylines this code compiled with 0 errors. However, when I install then crashed shows it can't open.

If i remove mylines then it works well . What is the problem i can't figure out?

canvas.drawPath(myLines, greenPaint);

package com.bennyplo.graphics2d;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.provider.DocumentsContract;
import android.view.View;

public class MyView extends View {
    private Paint redPaint;
    private Paint bluep;
    private Paint greenPaint;
    private  Path myLines;

    public MyView(Context context) {
        super(context, null);
        //Add your initialisation code here
        redPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
        redPaint.setStyle(Paint.Style.STROKE);//stroke only no fill
        redPaint.setColor(0xffff0000);//color red
        redPaint.setStrokeWidth(5);//set the line stroke width to 5

        bluep = new Paint(Paint.ANTI_ALIAS_FLAG);
        bluep.setStyle(Paint.Style.STROKE);
        bluep.setColor(0xFF3353EC);
        bluep.setStrokeWidth(5);


        greenPaint = new Paint();
        greenPaint.setStyle(Paint.Style.STROKE);
        greenPaint.setARGB(255, 0, 255, 0);
        greenPaint.setStrokeWidth(5);//set the line stroke width to 5

        Path mylines = new Path();
        myLines.moveTo(0, 0);
        myLines.lineTo(1, 1);
        myLines.lineTo(2, 2);
        myLines.lineTo(3, 3);
        myLines.lineTo(4, 4);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        //Add your drawing code here
        canvas.drawRect(500, 500, 700, 700 ,redPaint);
        canvas.drawCircle(600, 600, 145, bluep);
        canvas.drawPath(myLines, greenPaint);
    }
}

java
android
path
asked on Stack Overflow Jul 24, 2020 by Sazib • edited Jul 24, 2020 by Dennis Kozevnikoff

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0