EDIT : Solved. It was a silly silly mistake! Thanks for the fast response. I have 6 arrays each having 150-200 elements . Now when I try to select the index numbers, the first two are selected jolly well but starting from the third index number, the app begins to crash. App had only one activity.
String A[]={};
String B[]={};
...
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void generate(View v) {
tToast("Insult on your beep!");
Gener();
}
public void Gener()
{
int i1 = new Random().nextInt(A.length);
String r1 = (A[i1]);
int i2 = new Random().nextInt(B.length);
String r2 = (A[i2]);
int i3 = new Random().nextInt(C.length);
String r3 = (A[i3]);
int i4 = new Random().nextInt(D.length);
String r4 = (A[i4]);
int i5 = new Random().nextInt(E.length);
String r5 = (A[i5]);
int i6 = new Random().nextInt(F.length);
String r6 = (A[i6]);
String fin = r1 + r2 +r3 + r4 +r5 +r6;
//Works OK up to r2 but from r3 error occurs
final TextView mTextView = (TextView) findViewById(R.id.Gen);
mTextView.setText(fin);
tToast("Me works");
}
private void tToast(String s) {
Context context = getApplicationContext();
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, s, duration);
toast.show();
}
Aucun commentaire:
Enregistrer un commentaire