我重用ImageViews为我的显示,但在某些时候,我没有值把它。
那么如何在Android中清除ImageView呢?
我试过了:
mPhotoView.invalidate();
mPhotoView.setImageBitmap(null);
他们都没有清除视图,它仍然显示以前的图像。
我重用ImageViews为我的显示,但在某些时候,我没有值把它。
那么如何在Android中清除ImageView呢?
我试过了:
mPhotoView.invalidate();
mPhotoView.setImageBitmap(null);
他们都没有清除视图,它仍然显示以前的图像。
当前回答
我能指出你都试图设置和int它期望一个可绘制。
你不应该做以下事情吗?
imageview.setImageDrawable(this.getResources().getDrawable(R.drawable.icon_image));
imageview.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.icon_profile_image));
其他回答
editText.setText (" ");
imageView.setImageResource(0);
嘿,我知道我回答这个问题已经很晚了,但我想我必须分享这个,
当你重置图像时调用的方法必须与你设置图像时调用的方法相同。
当你想重置图片源@dennis。只有当你最初使用setImageResource()在位图中设置图像时,shepard回答才能正常工作。
例如,
我已经使用setImageBitmap(),因此设置setImageResource(0)没有工作,而不是我使用setImageBitmap(null)。
对于ListView项目图像,您可以在列表适配器中设置ImageView.setVisibility(View.INVISIBLE)或ImageView.setImageBitmap(null),用于“无图像”情况。
我能指出你都试图设置和int它期望一个可绘制。
你不应该做以下事情吗?
imageview.setImageDrawable(this.getResources().getDrawable(R.drawable.icon_image));
imageview.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.icon_profile_image));
听起来好像你想要的是一个默认图像,当ImageView没有显示不同的图像时设置它。联系人应用程序是这样做的:
if (photoId == 0) {
viewToUse.setImageResource(R.drawable.ic_contact_list_picture);
} else {
// ... here is where they set an actual image ...
}