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

时间:2018-08-01 10:39:19

标签: android

我有一个代码,如果在数据库上找不到图像,则会分配一个默认图像,我该如何不分配任何东西,谢谢:

buttonSignIn = Button(root, text="Sign in", width=10, bg='black', fg='white', command=new_winF).place(
x=30, y=130)

2 个答案:

答案 0 :(得分:2)

设置为

contactProfile.setBackgroundResource(0);

答案 1 :(得分:1)

设置为

          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;
}