@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder vh; if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.item_daily, null); vh = new ViewHolder(); vh.ivPic = (ImageView) convertView.findViewById(R.id.ivPic); vh.tvDate = (TextView) convertView.findViewById(R.id.tvDate); vh.tvTemp = (TextView) convertView.findViewById(R.id.tvTemp); vh.tvDescription = (TextView) convertView.findViewById(R.id.tvDescription); vh.tvWind = (TextView) convertView.findViewById(R.id.tvWind); vh.tvClouds = (TextView) convertView.findViewById(R.id.tvClouds); convertView.setTag(vh); } else { vh = (ViewHolder) convertView.getTag(); } Forecast forecast = mForecastList.get(position); vh.ivPic.setImageResource(R.drawable.no_image); if (forecast.getPicUrl() != null) { ImageLoader.getInstance().displayImage(forecast.getPicUrl(), vh.ivPic); } vh.tvDate.setText(forecast.getMonth() + " " + forecast.getDay()); vh.tvTemp.setText(getTemperature(forecast)); vh.tvDescription.setText(forecast.getDescription()); vh.tvWind.setText(forecast.getWindSpeed() + ", " + forecast.getWindDegree()); vh.tvClouds.setText(forecast.getCloudiness()); return convertView; }
private String getTemperature(Forecast forecast) { String temperature; switch (mMeasureId) { case 0: temperature = forecast.getTemperatureK(); break; case 1: temperature = forecast.getTemperatureC(); break; case 2: default: temperature = forecast.getTemperatureF(); break; } return temperature; }