I have a an array of objects and would like to be able to randomly choose one from the list when a button is pressed. How would you do that in Android?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Is this something you are looking for?
I use java.util.random.
It's basically plain java at this point. You can use java.util.nextInteger().
Do something like this inside your onClickListener
Something like that.
EDIT: Actually if it is an ArrayList then it will be more like this