@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { // inflate item layout LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.item_exercise, parent, false); // initialize view holder holder = new ViewHolder(); holder.thumbnail = (ImageView) convertView.findViewById(R.id.thumbnail); holder.description = (TextView) convertView.findViewById(R.id.description); holder.description.setTypeface(AndroidUtils.robotoRegular(getContext())); holder.minsValue = (TextView) convertView.findViewById(R.id.mins_value); holder.repsValue = (TextView) convertView.findViewById(R.id.reps_value); holder.setsValue = (TextView) convertView.findViewById(R.id.sets_value); convertView.setTag(holder); } else { // recycle view holder = (ViewHolder) convertView.getTag(); } // update item view Exercise listItem = getItem(position); holder.description.setText(listItem.getDescription()); holder.minsValue.setText(Utils.zeroPaddedNumber(listItem.getMinutes(), 2)); holder.repsValue.setText(Utils.zeroPaddedNumber(listItem.getRepetitions(), 2)); holder.setsValue.setText(Utils.zeroPaddedNumber(listItem.getSets(), 2)); return convertView; }
public void setUpHeader(View header) { Typeface robotoBold = AndroidUtils.robotoBold(this.context); TextView patientID = (TextView) header.findViewById(R.id.menu_patient_id); TextView patientIDSubtitle = (TextView) header.findViewById(R.id.menu_subtitle_patient_id); TextView nextVisit = (TextView) header.findViewById(R.id.menu_next_visit); TextView nextVisitSubtitle = (TextView) header.findViewById(R.id.menu_subtitle_next_visit); TextView week = (TextView) header.findViewById(R.id.menu_week); TextView weekSubtitle = (TextView) header.findViewById(R.id.menu_subtitle_week); patientID.setText(DataManager.getCurrentPatient().getUserID()); patientID.setTypeface(robotoBold); patientIDSubtitle.setText(context.getResources().getString(R.string.patient_id_subtitle)); // set localized date for next visit Locale locale = context.getResources().getConfiguration().locale; Date nextDate = DataManager.getCurrentPatient().getDateOfNextVisit(); nextVisit.setText(Utils.localizedDateWithoutYear(nextDate, locale)); nextVisit.setTypeface(robotoBold); nextVisitSubtitle.setText(context.getResources().getString(R.string.next_visit_subtitle)); week.setText( "Visit " + DataManager.getCurrentPatient().getVisitsUsed() + "/" + DataManager.getCurrentPatient().getVisitsTotal()); week.setTypeface(robotoBold); weekSubtitle.setText(context.getResources().getString(R.string.week_subtitle)); }