如何从模拟器的SD卡中的所有图片和列表视图显示呢? [英] How to get all the pictures from the sdcard of emulator and display it in a listView?
本文介绍了如何从模拟器的SD卡中的所有图片和列表视图显示呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个在我的模拟器的SD卡称为图像文件夹。此文件夹包含从我的应用程序点击图片。我想,以显示该文件夹中的所有图片到ListView。我怎样才能做到这一点?先谢谢了。
I have a folder called images in the sdcard of my emulator. This folder contains pictures clicked from my application. I want to display all the pictures from that folder to a listview. How can i do that? Thanks in advance.
推荐答案
这应该让你开始吧。
的http://android-er.blogspot.com/2010/01/android-file-explorer-with-jpgs-exif_08.html
一个简单的逻辑来计算的质量要求,
A simple logic to calculate the requirments,
private void getDir(String dirPath)
{
myPath.setText("Location: " + dirPath);
item = new ArrayList<String>();
path = new ArrayList<String>();
File f = new File(dirPath);
File[] files = f.listFiles();
if(!dirPath.equals(root))
{
item.add(root);
path.add(root);
item.add("../");
path.add(f.getParent());
}
for(int i=0; i < files.length; i++)
{
File file = files[i];
path.add(file.getPath());
if(file.isDirectory())
item.add(file.getName() + "/");
else
item.add(file.getName());
}
ArrayAdapter<String> fileList =
new ArrayAdapter<String>(this, R.layout.row, item);
setListAdapter(fileList);
}
这篇关于如何从模拟器的SD卡中的所有图片和列表视图显示呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文