S
S
smoklew2015-01-02 19:05:50
Android
smoklew, 2015-01-02 19:05:50

Random object selection on Andorid?

Hello!
Can someone help write code so that when a button is clicked, an object from the directory is randomly selected.
android.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2015-01-02
@IceJOKER

file or class (class object) ? O_O

Random r=new Random();
        File path=new File("/dir");
        File[] fileList=path.listFiles();
        int index=(r.nextInt(fileList.length));

Learn to use the search, such questions have long been asked and answered

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question