everyone, Please help me!
I want to show an array of numbers in a shape.
What I did
1) I draw a shape with canvas in View class.
2) I create a single random number.
3) I've searched a lot & find out that should use Drawtext to show a text or number.
4) I've read the documentation of Random, Drawtext, etc.
5) I've tried for loop but it didn't work outside of canvas class & inside, also will repeat that single number infinite times.
my Problem
I don't know how to put that number in an array & how to show array with drawtext in view class.
at the moment, I can show only one random number, but a want to show an array of random numbers.
I'm very new in Android & my English is not so good. I'll be very grateful if anybody can Help me through this.
Thank You.
Here's the part of my code that I used for creating a single random number (this is outside of class, constructor & onDraw method) :
Random rand = new Random();
int number = rand.nextInt(100) + 1;
String mystring = String.valueOf(number);
& in onDraw method for showing this number i used below code :
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawText(mystring,130,480,black_paintbrushstroke);
}
Aucun commentaire:
Enregistrer un commentaire