RecyclerView makes imageview disappear [closed]

0

Simple. The Recycler View causes the imageView to disappear after I scroll to the bottom of the list and go back to the top. For example, in the case, the first image simply disappears.

It was like this: link After going to the bottom of the list and back, it looks like this: link

I'm not using any library. The imageview of this is normal without any change. Even this photo is a background that I put in XML.

The texts do not change, you can see.

    
asked by anonymous 18.10.2016 / 20:59

1 answer

3

It's good to put the code next to the question, to help with the solution.

But this "problem" is already known in RecyclerView.

You have an adapter that creates your list, right?

Probably at the time you set the image, you're using an IF, right?

Whenever you go to work with the RecyclerView + Adapter, you should think of ELSE too, because as the name says, it recycles the cells to create the rest of the list.

For example:

if(url.imgview != null){
    image.setImageURI(Uri.parse(url.imgview));             
} else {
    image.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_launcher));   
}

If the URL is empty or null, the application icon will automatically be placed, thus avoiding that the already placed images will be repeated.

    
18.10.2016 / 21:12