@Override public View getView(final int position, final View convertView, final ViewGroup parent) { View view = convertView; if (view == null) { final LayoutInflater vi = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = vi.inflate(this.viewId, null); if ((this.itemHight == 0) && (this.withDescription)) { this.itemHight = view.findViewById(R.id.category_list_view_description_field).getHeight(); } } final TimeSliceCategory category = this.items.get(position); if (category != null) { final TextView nameView = (TextView) view.findViewById(R.id.category_list_view_name_field); final TextView descriptionView = (TextView) view.findViewById(R.id.category_list_view_description_field); final TextView activeView = (TextView) view.findViewById(R.id.category_list_view_active_field); if (this.withDescription) { this.setContent(descriptionView, this.descriptionPrefix, category.getDescription()); this.setContent(activeView, "", category.getActiveDate()); this.setContent(nameView, this.namePrefix, category.toString()); } else { this.setContent(descriptionView, "", null); this.setContent(activeView, "", null); this.setContent(nameView, "", category.toString()); } } return view; }
private CategoryListAdapterDetailed( final Context context, final int textViewResourceId, final List<TimeSliceCategory> items, final boolean withDescription) { super(context, textViewResourceId, items); this.items = items; this.context = context; this.withDescription = withDescription; this.viewId = textViewResourceId; this.namePrefix = context.getString(R.string.category_name) + " "; this.descriptionPrefix = context.getString(R.string.category_description) + " "; TimeSliceCategory.setCurrentDateTime(TimeTrackerManager.currentTimeMillis()); }