How can i check does image set in ImageView or no, exists standard methods?
ImageView imgV;
imgV = 开发者_开发问答(ImageView)findViewById(R.id.imageView);
if(imgV != set) ///!!!!!
imgV.setImageBitmap(mBitmap);
else
imgV.setImageBitmap(null);
What are you trying to accomplish by calling setImageBitmap(null)
? If you're trying to make it such that the ImageView
has no bitmap and thus doesn't appear, you should use the getVisibility()
and setVisibility()
methods in the View
class. I'm not sure if this is what you're looking for, but
ImageView imgV;
imgV = (ImageView)findViewById(R.id.imageView);
if(imgV.getVisibility() == View.INVISIBLE) { //or use View.GONE
imgV.setImageBitmap(mBitmap);
imgV.setVisibility(View.VISIBLE);
}
else {
imgV.setImageBitmap(null);
imgV.setVisibility(View.INVISIBLE); //or use View.GONE
}
You can check ImageView by,
if(imageView.getDrawable==null)
{
//imageview is set
}
else
{
//imageview is set
}
精彩评论