I know how to work with lists, for example, depending on something, you need not only to do something with View , but also ... well, for example, if there is a link, then we show the download button ...
if(file.getLink() == null){ btn_download.setVisibility(View.GONE); } else{ btn_download.setVisibility(View.VISIBLE); } Or a shortened record ( if/else not important, the main thing is to consider both cases)
btn_download.setVisibility( file.getLink() == null ? View.GONE : View.VISIBLE); This, of course, is clear, but what about the View that you give to the library? After all, it is not known what she is doing there with him. So I ran into this problem. I have a list of photos uploaded through the Picasso library. Moreover, if there is no photo, then you need to show the placeholder. I implemented it like this
if(photo == null) { } else { Picasso.with(ctx). load(photo). resize(photoWidth, photoHeight). into(photo_iv); } In if tried to set a picture via setImageResource