현재 제가 코드 정리를 해보려고 하는데요
그 코드중에
public static BitmapDrawable getSeasonBitmapDrawble(Context context, String str_season){
BitmapDrawable img_season = null;
if(str_season.equals("13")){
img_season =BitmapDrawable)context.getResources().getDrawable(R.drawable.year13);
}else if(str_season.equals("15")){
img_season =BitmapDrawable)context.getResources().getDrawable(R.drawable.year15);
}else if(str_season.equals("14")){
img_season =BitmapDrawable)context.getResources().getDrawable(R.drawable.year14);
}
return img_season;
}
이런 코드가 있습니다.
str_season.equals("13") 이 부분은
String str_season = spinner.getSelectedItem().toString();
이렇게 해서 가져오구요.
코드는 다 반복되고 달라지는 건 값뿐들이거든요.
저거를 if 문으로 하려니 너무 길어져서요.
저걸 어떻게 간단하게 개선할 수 있을까요?