Source:
<code>public View setView(final View view, final String item, final boolean remove) { if (item == null) { return null; } if (inflater == null) { inflater = ((Activity) getContext()).getLayoutInflater(); } final ViewHolder holder; View v = view; if (v == null) { v = inflater.inflate(R.layout.download_queue_item, null); } holder = new ViewHolder(); holder.text = (TextView) v.findViewById(R.id.text); holder.info = (TextView) v.findViewById(R.id.info); holder.remove = (Button) v.findViewById(R.id.delete_from_queue); final cgCache cache = cgeoapplication.getInstance().loadCache(item, EnumSet.of(LoadFlag.LOAD_CACHE_BEFORE, LoadFlag.LOAD_DB_MINIMAL)); if (cache == null) { holder.text.setText(item); holder.text.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); holder.info.setText(""); } else { if (cache.getNameSp() == null) { cache.setNameSp((new Spannable.Factory()).newSpannable(cache.getName())); if (cache.isDisabled() || cache.isArchived()) { cache.getNameSp().setSpan(new StrikethroughSpan(), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } holder.text.setText(cache.getNameSp(), TextView.BufferType.SPANNABLE); holder.info.setText(Formatter.formatCacheInfoLong(cache, CacheListType.OFFLINE)); holder.text.setCompoundDrawablesWithIntrinsicBounds(CacheListAdapter.getCacheIcon(cache), null, null, null); } if (remove) { holder.remove.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CacheQueueAdapter.this.activity.removeCacheFromQueue(item); } }); holder.remove.setVisibility(View.VISIBLE); <START> } <END> return v; }</code><technical_language>need hide remove button in else case, reusing single view instance time. Basically explicitly set view property modified for a cache</technical_language>

Target:
public View setView(final View view, final String item, final boolean remove) { if (item == null) { return null; } if (inflater == null) { inflater = ((Activity) getContext()).getLayoutInflater(); } View v = view; if (v == null) { v = inflater.inflate(R.layout.download_queue_item, null); } ViewHolder holder = (ViewHolder) v.getTag(); if (holder == null) { holder = new ViewHolder(); holder.text = (TextView) v.findViewById(R.id.text); holder.info = (TextView) v.findViewById(R.id.info); holder.remove = (Button) v.findViewById(R.id.delete_from_queue); v.setTag(holder); } final cgCache cache = cgeoapplication.getInstance().loadCache(item, EnumSet.of(LoadFlag.LOAD_CACHE_BEFORE, LoadFlag.LOAD_DB_MINIMAL)); if (cache == null) { holder.text.setText(item); holder.text.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); holder.info.setText(""); } else { if (cache.getNameSp() == null) { cache.setNameSp((new Spannable.Factory()).newSpannable(cache.getName())); if (cache.isDisabled() || cache.isArchived()) { cache.getNameSp().setSpan(new StrikethroughSpan(), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } holder.text.setText(cache.getNameSp(), TextView.BufferType.SPANNABLE); holder.info.setText(Formatter.formatCacheInfoLong(cache, CacheListType.OFFLINE)); holder.text.setCompoundDrawablesWithIntrinsicBounds(CacheListAdapter.getCacheIcon(cache), null, null, null); } if (remove) { holder.remove.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CacheQueueAdapter.this.activity.removeCacheFromQueue(item); } }); holder.remove.setVisibility(View.VISIBLE); } else { holder.remove.setVisibility(View.GONE); } return v; }