我想使用以下代码设置图像视图的背景:
String color = (cursor.getString(cursor.getColumnIndex(NotesDbAdapter.KEY_COLOR)));
ImageView background=(ImageView)view.findViewById(R.id.album_image);
DecodeTask task = (DecodeTask)background.getTag(R.id.album_image);
background.setScaleType(ImageView.ScaleType.CENTER_CROP);
String imageCheck = (cursor.getString(cursor.getColumnIndex(NotesDbAdapter.KEY_IMAGE)));
if (imageCheck != 0){
background.setImageBitmap(BitmapFactory.decodeFile(imageCheck));
}
else if (color != null && !color.isEmpty()){
if (color.equals("1")){
task = new DecodeTask(background);
background.setImageResource(R.drawable.bluebg);
}
else if (color.equals("2")){
task = new DecodeTask(background);
background.setImageResource(R.drawable.greenbg);
}
else if (color.equals("3")){
task = new DecodeTask(background);
background.setImageResource(R.drawable.yellowbg);
}
else if (color.equals("4")){
task = new DecodeTask(background);
background.setImageResource(R.drawable.redbg);
}
else if (color.equals("5")){
task = new DecodeTask(background);
background.setImageResource(R.drawable.purplebg);
}
}
但是,当 imageCheck 等于 0 时,它不会读取进一步的代码并为图像设置默认背景。我应该怎么办?