Je suis en train de porter une de mes applications sur Android et je suis bloqué sur un point très basique. NSArray
et ensuite appeler :
int chosen = arc4random() % [array count];
textOutput.text = [array objectAtIndex: chosen];
mais je n'arrive pas à l'obtenir dans Android.
Tout ce dont j'ai besoin, c'est de définir manuellement le tableau et d'y sélectionner une chaîne de manière aléatoire.
----- Comment j'ai réussi à le faire -----
ArrayList<String> array = new ArrayList<String>();
array((new String("Blah, blah.")));
String randString = new String();
randString = array(new Random().nextInt(array()));
textBox.setText(randString, TextView.BufferType.EDITABLE);