I want to display some random sentence in my app. Since that piece of code is inside onCreate method , it is getting called each time the orientation of the app changes.
Here is my code for generating random list of array inside Oncreate method
int listlen = list.size(); // get the size and gen the random index
System.out.println("len" + listlen);
Random indexval = new Random();
int n = indexval.nextInt(listlen); // get random val
System.out.println("random num " + n);
I couldn't add this below line of code in my app
android:configChanges="orientation|screenSize|keyboardHidden"
because I am calculating the screen size manually when orientation changes and also due to some other issues I removed the above line of code. So , is it possible to generate the random list whenever the app opens ? Because I get different random words when orientation changes. Any help would be great !! Thanks
Aucun commentaire:
Enregistrer un commentaire