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

    1 answer 1

    Picasso uses setImageBitmap , so you need to load (but better once, and then just use Bitmap

     Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.yourimage); 

    But I realized more shortly, the bike, of course

     Picasso.with(ctx). load(photo == null ? "*" : photo). error(R.drawable.no_image). resize(photoWidth, photoHeight). into(photo_iv); 

    Ie, if there is no link, I deliberately pass a non-existent link, thereby causing an error: D