次のコードを使用してイメージビューの背景を設定したい:
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 の場合、それ以上のコードは読み取らず、画像のデフォルトの背景を設定します。私は何をすべきか?