从对SD卡的特定文件夹加载图像? [英] load Image from specific folder on the sdcard?

查看:156
本文介绍了从对SD卡的特定文件夹加载图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个装有从驻留在一个SD卡的特定文件夹的图像画廊/ gridview的。该文件夹的路径是已知的,(MNT / SD卡/ iWallet /图像),但在我的例子已经看到了网上,我不能确定如何或在哪里指定路径的图片文件夹,我想从载入图像。我已经经历了几十个教程的阅读,甚至HelloGridView教程在developer.android.com但这些教程不教我什么,我求。

I'm attempting to create a gallery/gridview that is loaded with images from a specific folder that resides on an SDCard. The path to the folder is known, ("mnt/sdcard/iWallet/Images") , but in the examples I've seen online I am unsure how or where to specify the path to the pictures folder I want to load images from. I have read through dozens of tutorials, even the HelloGridView tutorial at developer.android.com but those tutorials do not teach me what i am seeking.

到目前为止,我已阅读每一个教程有两种:

Every tutorial I have read so far has either:

A)被称为图像从/ res文件夹被拉伸并把它们放到一个数组加载,不使用SD卡都没有。

A) called the images as a Drawable from the /res folder and put them into an array to be loaded, not using the SDCard at all.

B)形成

C)使用BitmapFactory,我没有丝毫的线索如何使用建议。

C) Suggested using BitmapFactory, which I haven't the slightest clue how to use.

如果我在错误的道路要对此,请让我知道,我直接朝着正确的方法做我想要做的。

If I'm going about this in the wrong way, please let me know and direct me toward the proper method to do what I'm trying to do.

我的目标的Andr​​oid SDK版本1.6 ...

my target android sdk version 1.6...

感谢..

推荐答案

您可以直接创建<一个位图href=\"http://developer.android.com/reference/android/graphics/BitmapFactory.html#de$c$cFile%28java.lang.String%29\"相对=nofollow>德codeFILE(字符串pathname)按,这将使你可以在ImageView的设置位图对象

You can directly create Bitmaps from decodeFile (String pathName) that will give you Bitmap object that can be set on ImageView

更新:下面是须藤code有轻微错误的修改,以满足您的需求。

Update: Below is sudo code with minor errors modify it to suit your needs

File path = new File(Environment.getExternalStorageDirectory(),"iWallet/Images");
if(path.exists())
{
    String[] fileNames = path.list();
}
for(int i = 0; i < filename.length; i++)
{
     Bitmap mBitmap = Bitmap.decodeFile(path.getPath()+"/"+ fileNames[i]);
     ///Now set this bitmap on imageview
} 

这篇关于从对SD卡的特定文件夹加载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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