public CategoryItemListAdapter( QuizApp quizApp, int resource, List<Category> objects, DataInputListener<Category> clickListener) { super(quizApp.getActivity(), resource, objects); this.quizApp = quizApp; this.clickListener = clickListener; }
@Override public View getView(int position, View convertView, ViewGroup parent) { CategoryViewHolder holder; Category category = getItem(position); if (convertView == null) { convertView = quizApp.getActivity().getLayoutInflater().inflate(R.layout.list_item_layout, null); holder = new CategoryViewHolder(); holder.imageView = (ImageView) convertView.findViewById(R.id.imageView1); holder.categoryName = (GothamTextView) convertView.findViewById(R.id.category_item_name); holder.shortCategoryDescription = (GothamTextView) convertView.findViewById(R.id.category_short_name); holder.additionalText = (GothamTextView) convertView.findViewById(R.id.additional_text); holder.additionalText.setVisibility(View.GONE); convertView.setTag(holder); if (clickListener != null) convertView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { clickListener.onData(((CategoryViewHolder) v.getTag()).category); } }); } else { holder = (CategoryViewHolder) convertView.getTag(); } holder.category = category; quizApp .getUiUtils() .loadImageIntoView( quizApp.getContext(), holder.imageView, getItem(position).assetPath, true); holder.categoryName.setText(category.description); holder.shortCategoryDescription.setText(category.shortDescription); // holder.additionalText.setText("a"); return convertView; }