0

我们如何在运行时从 sdcard 中的特定文件夹检索或复制图像到可绘制文件夹。基本上我想显示与给定链接相同的幻灯片,但问题是他们正在从可绘制文件夹中检索所有图像,而我想从某个 sdcard 文件夹中检索。我是android的初学者,所以请帮助我。

here is the link : 

http://www.edumobile.org/android/android-development/image-gallery-example-in-android/
4

1 回答 1

0

res/drawable 文件夹中的资源被编译和优化。请查看 http://www.linuxtopia.org/online_books/android/devguide/guide/topics/resources/android_resources-i18n_CreatingResources.html

如果您想在 sdcard 上使用图像,则必须从文件中加载它们。简单的例子是:

Bitmap bitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
jpgView.setImageDrawable(bitmap);

简而言之。可绘制文件夹以特殊方式处理。

参数 imageFile 是类 File 的对象。 http://developer.android.com/reference/java/io/File.html

变量 jpgView 是类 ImageView 的一个实例。但这只是一个例子。 http://developer.android.com/reference/android/widget/ImageView.html

就您的循环而言,您将不得不遍历文件夹中的文件。请查阅相关文档。

于 2013-02-14T07:36:36.763 回答