Note that there are some explanatory texts on larger screens.

plurals
  1. PORepeated ImageView in ListView every 4 item
    text
    copied!<p>Here's my problem:</p> <p>I have a ListView with an ImageView that at first is set to GONE, but after doing some stuff on the custom adapter y set it to visible.</p> <p>My problem is that if I select the first element of the list,every four item also sets it's image to VISIBLE.</p> <p>I hope I've explained myself. If any doubt don't hesitate to ask me.</p> <p>I edit to add some code. Some parts are in Spanish as I am Spanish.</p> <p>getView(): View v = convertView;</p> <pre><code> if (v == null) { LayoutInflater vi = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.list_view_item, null); } final Oferta o = items.get(position); boolean comprado = false; if (o != null) { final ImageView image = (ImageView) v.findViewById(R.id.imageView1); TextView titulo = (TextView) v.findViewById(R.id.textView1); TextView precioAnterior = (TextView) v.findViewById(R.id.textView2); TextView precioNuevo = (TextView) v.findViewById(R.id.textView3); TextView fechaHasta = (TextView) v.findViewById(R.id.textView4); ImageView imageComprado = (ImageView) v.findViewById(R.id.imageView2); Drawable compra = this.getContext().getResources().getDrawable(R.drawable.comprada); for(int i = 0; i &lt; MainActivity.tickets.size();i++) { if((MainActivity.tickets.get(i).getOferta().getId()) == (o.getId())) { System.out.println("tickets: " + MainActivity.tickets.get(i).getOferta().getId()); System.out.println("oferta: " + o.getId()); comprado = true; break; } } if (comprado) { imageComprado.setVisibility(View.VISIBLE); comprado = false; } if (titulo != null) { titulo.setText(o.getTitulo()); } if(precioAnterior != null){ precioNuevo.setText(String.valueOf(new java.text.DecimalFormat("#.##").format(o.getPrecioNuevo()))+"€"); } if(precioNuevo != null){ precioAnterior.setPaintFlags(precioAnterior.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); precioAnterior.setText(String.valueOf(new java.text.DecimalFormat("#.##").format(o.getPrecioAnterior()))+"€"); } if(fechaHasta != null){ fechaHasta.setText("Cad.: " + o.getDisponibleHasta()); } if(image != null){ DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory() .cacheOnDisc() .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getContext()) .defaultDisplayImageOptions(defaultOptions) .build(); ImageLoader.getInstance().init(config); //imageLoader.init(ImageLoaderConfiguration.createDefault(getApplicationContext())); ImageLoader.getInstance().displayImage(o.getImagen(), image); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload