Android 如果找不到图像,如何不为setBackgroundRessource分配任何内容

Android 如果找不到图像,如何不为setBackgroundRessource分配任何内容,android,Android,我有一个代码,其中指定了默认图像。如果在数据库中找不到图像,我怎么能不指定任何内容,谢谢: case R.id.child2 : ImageView contactProfile = (ImageView) view; byte[] imageBytes = cursor.getBlob(cursor.getColumnIndex(Database.DATABASE_CHILD_2)); if(imageBy

我有一个代码,其中指定了默认图像。如果在数据库中找不到图像,我怎么能不指定任何内容,谢谢:

        case R.id.child2 :
            ImageView contactProfile = (ImageView) view;
            byte[] imageBytes = cursor.getBlob(cursor.getColumnIndex(Database.DATABASE_CHILD_2));
            if(imageBytes != null ){
                // Pic image from database
                contactProfile.setImageBitmap(BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length));
            }else {
                // If image not found in database , assign a default image
                contactProfile.setBackgroundResource(R.drawable.disorders);
            }
            break;
    }
设为

contactProfile.setBackgroundResource(0);

          case R.id.child2 :
        ImageView contactProfile = (ImageView) view;
        byte[] imageBytes = cursor.getBlob(cursor.getColumnIndex(Database.DATABASE_CHILD_2));
        if(imageBytes != null ){
            // Pic image from database
            contactProfile.setImageBitmap(BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length));
        }else {
            // If image not found in database , assign a default image
            contactProfile.setBackgroundResource(0);
        }
        break;
}

我认为这与此类似: