因此,我遇到了在切换情况下绑定视图的问题。我将创建一个方法,该方法将根据实际天气正确设置ImageView。
在使用ButterKnife之前,此方法如下所示:
public void setWeatherIcon() {
switch (forecastInfo) {
case "clear sky":
weatherIcon.setImageResource(R.drawable.day_clear_sky);
break;
case "few clouds":
weatherIcon.setImageResource(R.drawable.day_few_clouds);
break;
case "scattered clouds":
weatherIcon.setImageResource(R.drawable.scattered_clouds);
break;
case "broken clouds":
weatherIcon.setImageResource(R.drawable.broken_clouds);
break;
case "light rain":
weatherIcon.setImageResource(R.drawable.shower_rain);
break;
case "rain":
weatherIcon.setImageResource(R.drawable.day_rain);
break;
case "thunderstorm":
weatherIcon.setImageResource(R.drawable.thunderstorm);
break;
case "snow":
weatherIcon.setImageResource(R.drawable.snow);
break;
case "mist":
weatherIcon.setImageResource(R.drawable.mist);
break;
}
}
现在,在使用ButterKnife之后,我再也不能使用切换大小写了(我只向您展示第一种情况)
public void setWeatherIcon() {
switch (forecastInfo) {
case "clear sky":
@BindDrawable(R.drawable.day_clear_sky); *
break;