Recyclerview Images with Problem loading images==null

Asked

Viewed 402 times

0

Hello, everybody.

I’m making a Recyclerview with a Textview and an Imageview that is loaded from the bank. The problem is when this image is null. Recycler View goes well into a certain part and then it starts to put images that don’t exist where there is image==null.

I tried it with Picasso and Fresco, and it’s the same mistake. And it’s not every time that it happens, just sometimes, randomly. The Views that have picture are perfect.

I’m doing a random, so that the data is displayed randomly. Can someone help me? I’m using the following:

     Random gerador = new Random();
    position = gerador.nextInt(listadicas.size());

    final ParseObject dican = listadicas.get(position);


    holder.tituloDica.setText(dican.getString("nome"));


        if (dican.getParseFile("foto") != null) {
            holder.fotodica.setVisibility(View.VISIBLE);
            holder.fotodica.setImageURI(dican.getParseFile("foto").getUrl());

        }

Thank you

  • tries to leave the imageview with "imgView.setVisibility(View.GONE);" when there are no images.

  • Hey, Anderson. I’ve tried, but it happens anyway .

  • Have to paste your recyclerview all over here?

2 answers

1


if (dican.getParseFile("foto") != null) {       
    holder.fotodica.setImageURI(dican.getParseFile("foto").getUrl());
}else{
    holder.fotodica.setImageURI("www.url.com/imagem.png");     
}

0

if (dican.getParseFile("foto") != null) {
    holder.fotodica.setVisibility(View.VISIBLE);  
    holder.fotodica.setImageURI(dican.getParseFile("foto").getUrl());
}else{
    holder.fotodica.setVisibility(View.INVISIBLE);          
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.