문제

I have a list of path objects which are rectangles stored in an arraylist.

This is my code as shown below:

    for (RectF rec : rects) {

        for( int i =0; i< rects.size(); i++){

            System.out.println(rects.get(i).height() + "g");
            while(rects.get(i).height() !=50 ){

                canvas.drawRect(rec, paint);
            }
                canvas.drawOval(rec, paint);

            }

    }

Basically, when the rectangle height is not equal to 50, I would like to draw an oval instead of a rectangle. Upon running the code above, both the oval and rectangle was drawn. What is wrong here? Please help thank you.

도움이 되었습니까?

해결책

for (RectF rec : rects) {
    System.out.println(rec.height() + "g");

    if(rec.height() != 50)
    {
        canvas.drawOval(rec, paint);
    }
    else
    {
        canvas.drawRect(rec, paint);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top