Mar*_*eiz 6 android listview image hashmap simplecursoradapter
我正在读取手机上所选文件夹中的文件,就像您在下面的代码中看到的那样.我怎么能用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);
Run Code Online (Sandbox Code Playgroud)
在下面的图片中,我喜欢用名为"41786486733.jpg"的原始图片替换白色"图像"图片作为预览.这样用户就可以看到这是什么图片......
编辑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);
}
Run Code Online (Sandbox Code Playgroud)
我的问题的解决方案在这里:
\n\n\n\n我必须创建一个自定义列表视图(在 \xcf\x81\xd1\x8f\xcf\x83\xd1\x95\xcf\x81\xd1\x94\xd1\x8f K 的帮助下)谢谢!
\n\n通过扩展的 baseadapter 类而不是 SimpleAdapter 创建自定义适配器。我认为这很容易,或者您也可以创建更多自定义 UI 而不是使用 inbuild
\n 归档时间: |
|
查看次数: |
1405 次 |
最近记录: |