I am reading files from the selected folder on my phone like you can see in the following code. And how could I get this work with an Imagefile? At the end I like to have an imagelist with a preview of every image. Like that:
[IMG] (imgview) - [Filename] (String)
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);
In the following picture I like to replace the white "image" picture with the original picture called "41786486733.jpg" as preview. So that the user can see what picture this is...
EDIT FLORIAN PILZ
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);
}