適当に作ってみたけど、境界値あたりでバグがでてしまってます
作り替えますが、記録としてのこしておきます
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Random;
public class Bingo extends Activity
implements View.OnClickListener {
ArrayList array = new ArrayList();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.Button01);
btn.setOnClickListener(this);
}
public void onClick(View v) {
Random rand = new Random();
int value = rand.nextInt(75)+1;
for(int i=0; i if (array.get(i)== value && array.size() != 0) {
value = rand.nextInt(75)+1;
i = 0;
}
}
if (array.size() <= 75) {
array.add(value);
}
TextView textView = (TextView)findViewById(R.id.TextView01);
textView.setTextSize(50);
textView.setText(Integer.toString(value));
String out = "";
for(int i=0; i String s = String.format("%1$02d",array.get(i));
if ((i+1)%10 == 0) {
out = out + s + ",\n";
} else {
out = out + s + ",";
}
}
TextView textView2 = (TextView)findViewById(R.id.TextView02);
textView2.setText(out);
}
}
作り替えますが、記録としてのこしておきます
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Random;
public class Bingo extends Activity
implements View.OnClickListener {
ArrayList
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.Button01);
btn.setOnClickListener(this);
}
public void onClick(View v) {
Random rand = new Random();
int value = rand.nextInt(75)+1;
for(int i=0; i
value = rand.nextInt(75)+1;
i = 0;
}
}
if (array.size() <= 75) {
array.add(value);
}
TextView textView = (TextView)findViewById(R.id.TextView01);
textView.setTextSize(50);
textView.setText(Integer.toString(value));
String out = "";
for(int i=0; i
if ((i+1)%10 == 0) {
out = out + s + ",\n";
} else {
out = out + s + ",";
}
}
TextView textView2 = (TextView)findViewById(R.id.TextView02);
textView2.setText(out);
}
}