Android的 - 在加载SD卡中的图像更好的办法 [英] Android - Better Approach in Loading SD CARD Images

查看:217
本文介绍了Android的 - 在加载SD卡中的图像更好的办法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是装货或从SD卡图像填充一个更好的算法,不是存储每个图像路径作为常量?

What is a better algorithm on loading or populating images from SD CARD, than storing each image path as Constants?

public final class Constants {

        public static final String[] IMAGES = new String[] {
            // Heavy images
        "file:///mnt/sdcard/folder/folder/folder/1.jpg",
        "file:///mnt/sdcard/folder/folder/folder/2.jpg",
        "file:///mnt/sdcard/folder/folder/folder/3.jpg",
        "file:///mnt/sdcard/folder/4.jpg",
        );
}

基本上我学习的通用图像装载机,并专注于在加载图像网格视图实现。目前该项目正在运行,但它使用的是恒定的轨迹。事情是我的图片存储在SD卡中。

Basically I am learning the Universal Image Loader, and focusing on the grid view implementation in loading images. Right now the project is running but it is using the CONSTANT path. The thing is my images is stored in sd card.

LINK:
<一href=\"https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/sample/src/com/nostra13/example/universalimageloader/ImageGridActivity.java\" rel=\"nofollow\">https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/sample/src/com/nostra13/example/universalimageloader/ImageGridActivity.java

LINK2:存储路径字符串常量
<一href=\"https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/sample/src/com/nostra13/example/universalimageloader/Constants.java\" rel=\"nofollow\">https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/sample/src/com/nostra13/example/universalimageloader/Constants.java

LINK2: STORING PATH IN CONSTANT Strings https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/sample/src/com/nostra13/example/universalimageloader/Constants.java

推荐答案

如果它是一个固定的图像,这永远不会改变,你事先知道,我没有看到存储在一个字符串数组对它们的引用任何问题,这可能做到这一点的最好办法。

If it's a fixed set of images that never change that you know in advance, I don't see any problems with storing references to them in a String array, that's probably the best way to do it.

如果你想动态查找在运行时在SD卡上的图像,你会更好的扫描/获取特定文件夹或文件夹,您有兴趣的文件列表,并通过了对图像装载机。您可以查询 MediaStore ,也可以使用Java IO方法。

If you want to dynamically find images on the SD card at run-time you'd be better off scanning/getting a file list of the particular folder or folders you are interested in and passing that to the Image Loader. You can query the MediaStore or you can use Java IO methods.

有如何做到这一点的这样的例子很多:

There are many examples of SO how to do this:

  • http://stackoverflow.com/a/9531063/833647

无论哪种方式,通用图像装载机应当采取了很多位图显示侧繁重的,所以我不会担心太多。

Either way, Universal Image Loader should take a lot of the heavy-lifting on the bitmap-display side, so I wouldn't worry too much about that.

这篇关于Android的 - 在加载SD卡中的图像更好的办法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆