【发布时间】:2023-03-03 12:23:01
【问题描述】:
我正在尝试使用自定义图库并尝试获取所选图像并希望在列表视图中显示它
这就是我想要做的:
if (extras != null) {
for (int i = 0; i < fetchList.size(); i++) {
Bitmap originBitmap = null;
filepath = fetchList.get(i);
newStringList.add(filepath);
imgfilename = filepath.substring(filepath.lastIndexOf("/") + 1);
Uri selectedImage = Uri.fromFile(new File(filepath));
File myFile = new File(selectedImage.getPath());
myFile.getAbsolutePath();
Toast.makeText(MainActivity.this,myFile.getAbsolutePath(),Toast.LENGTH_LONG).show();
listimage.setImageBitmap(myFile.getAbsolutePath());
myStringList.add(imgfilename);
arrayAdapter = new ArrayAdapter<String>(
this,
R.layout.custom_textview, R.id.listtext,
myStringList);
lv.setAdapter(arrayAdapter);
arrayAdapter.notifyDataSetChanged();
}
}
现在我的问题是如何使用此路径将图像设置为图像视图?
如果我用这个listimage.setImageBitmap(myFile.getAbsolutePath()); 我看不到图片。
我得到的路径是:/storage/emulated/0/
【问题讨论】: