次のコードでわかるように、電話で選択したフォルダーからファイルを読み取っています。そして、どうすれば Imagefile でこれを機能させることができますか? 最後に、すべての画像のプレビューを含む画像リストを作成したいと思います。そのように:
[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);
}