I'm doing a simple addition game on android studio. Every time the "addition" activity is opened I was hoping to generate two random numbers in two text boxes. However I can't get it to work and the text box appears blank every time I run the app and open the activity. Here's my code for one of the text boxes.
public void textview2(View View) {
Random addition1 = new Random();
int additionint1 = addition1.nextInt(100)+1;
TextView additionText1 = (TextView) findViewById(R.id.textView2);
String additionString1 = String.valueOf(addition1);
additionText1.setText(additionString1);
}
Aucun commentaire:
Enregistrer un commentaire