【发布时间】:2012-05-16 13:07:02
【问题描述】:
我试图从外部SD card 内的特定文件夹中获取图像,并在运行应用程序时尝试将它们显示在列表中。没有提供错误,没有任何反应。任何建议都只是空白页。
我正在获取带有扩展名的图像列表,但我如何查看图像!
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
File file = new File("/sdcard/external_sd/folder_name/");
File imageList[] = file.listFiles();
ArrayList<Bitmap> images = new ArrayList<Bitmap>();
for(int i=0;i<imageList.length;i++)
{
Log.e("Image: "+i+": path", imageList[i].getAbsolutePath());
Bitmap b = BitmapFactory.decodeFile(imageList[i].getAbsolutePath());
images.add(b);
}
setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1,imageList));
}
【问题讨论】:
-
您确定位图解码正确吗?也可以考虑使用 new File(Environment.getExternalStorageDirectory(),"文件夹名称")。
-
setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1,imageList));我正在获取带有扩展名的图像列表,我怎样才能让它们出现?作为图像
-
Tony the Pony 这里是 listView ..
标签: android