Sorry if this is super basic, I'm just getting started with programming in general.
So I have this list, I've managed to display an object from it randomly when the user clicks on a button.
Here is the code that does this:
val listOfElement = listOf<String>(
"test", "test2", "test 3")
fun generateElement (view: View) {
tvDisplay.text = listOfElement.random()
}
It works fine but the problem is that an object (e.g "test3") can be displayed twice before it goes through the rest of the list.
So basically I'd like to:
- Only display each object only once BUT when all the objects have been displayed, then it should start again randomly.
Thanks again and sorry if this not appropriate - it's my first time on stackoverflow!
shuffle()ing the list.