-1

I have a code where a default image is assigned if no image is found on database, how could i assign nothing instead, thanks :

        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;
    }
Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
Errahbi Zouhair
  • 99
  • 2
  • 10
  • 1
    I think it is similar to this: https://stackoverflow.com/questions/6826564/remove-background-drawable-programmatically-in-android – Siim Puniste Aug 01 '18 at 10:43

2 Answers2

2

Set as

contactProfile.setBackgroundResource(0);
1

set like

          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;
}
amit
  • 659
  • 1
  • 8
  • 21