如何从SD卡读取文件并在listview中显示?

时间:2022-09-08 21:33:06

I would like to create a button that when clicked will go to a class that displays all media files from an SD card using a ListView.

我想创建一个按钮,单击该按钮将转到一个类,该类使用ListView显示SD卡中的所有媒体文件。

After selecting from the list it will then return the filename selected to the main class. IF the returned file is an image file, it will be displayed in an ImageView and if the returned file is an audio file, it'll display and on click play?

从列表中选择后,它将返回选择的主文件名。如果返回的文件是图像文件,它将显示在ImageView中,如果返回的文件是音频文件,它将显示并单击播放?

1 个解决方案

#1


You may find it interesting to use a library to consult the files in a directory and display it. This can save you lots of work if the requirements of your application permits. There are a lot of libraries for this pourpose, for example:

您可能会发现使用库查询目录中的文件并显示它很有趣。如果您的应用程序的要求允许,这可以为您节省大量的工作。这个pourpose有很多库,例如:

https://github.com/bartwell/ExFilePicker

Hope it helps you!!

希望它能帮到你!!

#1


You may find it interesting to use a library to consult the files in a directory and display it. This can save you lots of work if the requirements of your application permits. There are a lot of libraries for this pourpose, for example:

您可能会发现使用库查询目录中的文件并显示它很有趣。如果您的应用程序的要求允许,这可以为您节省大量的工作。这个pourpose有很多库,例如:

https://github.com/bartwell/ExFilePicker

Hope it helps you!!

希望它能帮到你!!