I have a application where i want to generate dots like 2 x 2, 3 x 3 and 4 x 4 dynamically

now i am drawing dot matrix without dynamic using code as follows :
if(test.equals("galmenu2"))
{
canvas.drawCircle(wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,5*ht/8,3, mPaint);
canvas.drawCircle(wid/4,5*ht/8,3, mPaint);
}
else if(test.equals("galmenu3"))
{
canvas.drawCircle(wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(wid/2,3*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,3*ht/8,3, mPaint);
canvas.drawCircle(wid/4,ht/2,3, mPaint);
canvas.drawCircle(wid/2,ht/2,3, mPaint);
canvas.drawCircle(3*wid/4,ht/2,3, mPaint);
canvas.drawCircle(wid/4,5*ht/8,3, mPaint);
canvas.drawCircle(wid/2,5*ht/8,3, mPaint);
canvas.drawCircle(3*wid/4,5*ht/8,3, mPaint);
}
else if(test.equals("galmenu4"))
{
for(wid=1/8;wid<1;wid+=2/8)
{
for(ht=5/16;ht<3/4;ht+=1/8)
{
canvas.drawCircle(wid,ht,3, mPaint);
}
}//this for loop crash the application
}
and i need a formula to generate dots in my center of canvas please help me
The code mentioned above is added in onDraw() method Thanks in advance
To draw
nbyncircles on the canvas, I’d use the following:What is happening here?
We loop through
n*ndrawing commands:(i+.5)/n, which is a number between0and1, which is the percentage of the width of the canaws where our coordinate is.