问题
I have been scouring the internet for a simple easy to implement Android file chooser dialog that also has the option of selecting multiple files and returning a uri or string array with all the files selected.
Currently I use aFileChooser on github and it is according to me better than android-file-dialog. But neither address the issue of passing multiple files.
I am only an intermediate android developer but I think this would be something not so hard to implement by a pro.
I have looked at the code of aFileChooser and I think adding a check box to the file item would be the way to go but as far as code is concerned i am clueless and the developer seems he's not really gonna work on it in the foreseeable future
So in short im requesting for help to either add the select multiple files option to aFileChooser via the github or here, or maybe suggest to me a better dialog that does what i want.
回答1:
I don't know any file chooser you could use, but I can show you how I made my own long time ago. It's actually pretty ugly, but it does what you ask for. You can select multiple files and an ArrayList<File>
is returned via Intent
.
So you could use it as an example of how to do it, and implement it yourself, if you really need it to (I wouldn't recommend you to use mine as it is now).
Here are the links to GitHub:
- FileSelectionActivity.
- Used layout file for the
FileSelectionActivity
. - MainActivity, on line 225 the
FileSelectionActivity
is started.
Below there's a screenshot of FileSelectionActivity
, as I said, ugly.
"Go Up" goes to a higher level of the file hierarchy, there are two ListView
s, one for directories and one for files. The files have checkboxes. When the share button is pressed, each item in the second ListView
is checked to see if the checkbox is active or not. That's line 71 of the FileSelectionActivity
file.
Anyways, I hope this helps you make your own file selector, or something.
回答2:
Thank's to the answer above, I've made a simple library that addresses the concern. It not only passes an array of file paths but you can also use to select a folder.
- It has thumbnails for image files
- auto scrolls to last scroll position
- will soon have language support for several locales
Here it is: https://github.com/tapaulo/Android-Multiple-file-Selector-Dialog
来源:https://stackoverflow.com/questions/22095441/android-multiple-file-selector-chooser-dialog