Source:
public View getView(int i, View view, ViewGroup viewGroup) { View convertedView = view; if (convertedView == null) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertedView = inflater.inflate(R.layout.list_view_item_layout, null); mViewHolder = new ViewHolder(); mViewHolder.addressHolder = (TextView) convertedView.findViewById(R.id.atm_address); mViewHolder.bankLogoHolder = (ImageView) convertedView.findViewById(R.id.atm_logo); mViewHolder.bankNameHolder = (TextView) convertedView.findViewById(R.id.atm_bank_name); mViewHolder.distanceView = (TextView) convertedView.findViewById(R.id.distance); mViewHolder.detailView = convertedView.findViewById(R.id.detail_id); ATMItem item = mATMList.get(i); mOnClickListener.setDetailItem(item); mViewHolder.detailView.setOnClickListener(mOnClickListener); convertedView.setTag(mViewHolder); } else { mViewHolder = (ViewHolder) convertedView.getTag(); } Should.beNotNull(convertedView, LOG_TAG + "; view should be not null!"); ATMItem item = mATMList.get(i); Should.beNotNull(item, LOG_TAG + ", ATMList should not contain null!"); mViewHolder.bankLogoHolder.setImageResource(item.getIconId()); mViewHolder.bankNameHolder.setText(item.getBankName()); mViewHolder.addressHolder.setText(item.getFullAddress()); float distance = mCurrentLocation.distanceTo(item.getLocation()); String dist; if (distance < 1000) { int newDistance = (int)distance; dist = newDistance + " " + mContext.getResources().getString(R.string.distance_meter); } else { float newDistance = Utils.round(distance / 1000,1); dist = newDistance + " " + mContext.getResources().getString(R.string.distance_kilometer); } mViewHolder.distanceView.setText(dist); return convertedView; }

Target:
public View getView(int i, View view, ViewGroup viewGroup) { View convertedView = view; if (convertedView == null) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertedView = inflater.inflate(R.layout.list_view_item_layout, null); mViewHolder = new ViewHolder(); mViewHolder.addressHolder = (TextView) convertedView.findViewById(R.id.atm_address); mViewHolder.bankLogoHolder = (ImageView) convertedView.findViewById(R.id.atm_logo); mViewHolder.bankNameHolder = (TextView) convertedView.findViewById(R.id.atm_bank_name); mViewHolder.distanceView = (TextView) convertedView.findViewById(R.id.distance); convertedView.setTag(mViewHolder); } else { mViewHolder = (ViewHolder) convertedView.getTag(); } Should.beNotNull(convertedView, LOG_TAG + "; view should be not null!"); ATMItem item = mATMList.get(i); Should.beNotNull(item, LOG_TAG + ", ATMList should not contain null!"); mViewHolder.bankLogoHolder.setImageResource(item.getIconId()); mViewHolder.bankNameHolder.setText(item.getBankName()); mViewHolder.addressHolder.setText(item.getFullAddress()); float distance = mCurrentLocation.distanceTo(item.getLocation()); String dist; if (distance < 1000) { int newDistance = (int)distance; dist = newDistance + " " + mContext.getResources().getString(R.string.distance_meter); } else { float newDistance = Utils.round(distance / 1000,1); dist = newDistance + " " + mContext.getResources().getString(R.string.distance_kilometer); } mViewHolder.distanceView.setText(dist); return convertedView; }