我正在阅读手机上选定文件夹中的文件,就像您在以下代码中看到的一样。 我怎样才能得到这个工作与Imagefile? 最后,我喜欢用图像列表预览每个图像。 喜欢的是:Android:如何使用simpleadapter将SD卡中的图像文件添加到HashMap中?
[IMG](imgview) - [文件名](字符串)
for(int i=0; i < files.length; i++) {
File file = files[i];
map = new HashMap<String, String>();
if(!file.isHidden() && file.canRead()) {
path.add(file.getPath());
if(file.isDirectory()) {
map.put("img_list", ""+R.drawable.folder);
map.put("string_cell", file.getName()+"/");
your_array_list.add(map);
}else{
ImageFileFilter filefilter = new ImageFileFilter(file);
if(filefilter.accept(file)){
//Its an imagefile
// ==> I like to replace the ""+R.drawable.image with the file that I have read
map.put("img_list", ""+R.drawable.image);
} else {
//Its not an image file
}
map.put("string_cell", file.getName());
your_array_list.add(map);
}
}
}
SimpleAdapter mSchedule = new SimpleAdapter(this, your_array_list, R.layout.connected_upload_row,
new String[] {"img_list", "string_cell"}, new int[] {R.id.img_list, R.id.string_cell});
list.setAdapter(mSchedule);
在下面的图片我喜欢称为“41786486733原始图象来代替白色 “图像” 的画面。 jpg“作为预览。 这样用户可以看到这是什么图片...
编辑弗洛里安皮尔茨
if(filefilter.accept(file)){
Log.v("PATH1", file.getPath());
ImageView myImageView = (ImageView) findViewById(R.id.img_list);
Bitmap bmp = BitmapFactory.decodeFile(file.getAbsolutePath());
myImageView.setImageBitmap(bmp);
}
你需要实现一个自定义列表视图,在这里看到的例子[链接] [1] [1 ]:http://stackoverflow.com/questions/10267103/add-a-new-item-to-a-listview/10267200#10267200 – pouzzler
为什么你两次创建HashMap实例'map = new HashMap ();'删除最后一个 –
益智游戏我与一个custon列表视图工作;) ρяσѕρєя每次当你有reinizialize HashMap的,否则它不工作... –