I am trying to create a Spinner or similar drop down/selector in Android. Similar to opening a file, I want the Spinner to list all of the files found in a specified directory path.
I.E. –> I have a directory with example1.txt, example2.txt, mymp3.mp3, otheraudio.3pg @ C://path/mystuff
I want the spinner to populate based on the files in the directory so you will have the option to pick any of the files in the directory.
The spinner is mainly a “display only” functionality. I just need it to get the file names of the files in the directory. There will be a button that will contain the functionality to open the selected file from the spinner.
Not sure how to go about setting this up… Would it be best to get all the file names through java, then store it in a string array in the XML for the spinner to read, or some other way?
Assuming that you’re talking about a directory on your phone (your reference to C://path/mystuff has confused me as this isn’t a Linux path) I don’t see that there are any benefits to creating an XML file to list the files. Is this just so you can use ArrayAdapter.createFromResource(…)?
You can just do something like the following: