java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference

前端 未结 6 1422
迷失自我
迷失自我 2021-01-06 01:16

I am trying to implement swipe to delete in RecyclerView. Everything seems to be working fine except drawing a delete icon below the item that\'s being swiped.

Thi

6条回答
  •  时光说笑
    2021-01-06 01:53

    Answer is check if bitmap is null or reycled() before passing it to ImageView.

    if(resource!==null && !resource.isRecycled)
        imageView.setImageBitmap(resource)
    

提交回复
热议问题