使用以下代码查看ImageView
中捕获的图像
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(this.requestCode == requestCode && resultCode == RESULT_OK) {
File imageFile = new File(Environment.getExternalStorageDirectory() + "/img.jpeg");
Picasso.with(MainActivity.this).load(imageFile).into(imageView);
}
}
问题:
如何刷新
ImageView
中的onActivityResult(...)
,如您所见,我正在使用上述代码,但始终获得旧图像的预览,而我正在存储中获取新图像 最佳答案
你可以用以下几行代码替换代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(this.requestCode == requestCode && resultCode == RESULT_OK) {
File imageFile = new File(Environment.getExternalStorageDirectory() + "/img.jpeg");
Picasso.with(MainActivity.this)
.load(imageFile)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.networkPolicy(NetworkPolicy.NO_CACHE)
.error(R.drawable.ic_lanucher)
.noFade()
.into(imageView)
}
}
关于android - OnActivityResult不会使用Picasso更新ImageView,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33752015/