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

前端 未结 6 1497
迷失自我
迷失自我 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:28

    I don't understand why it;s null since I've already assigned it a value.

    Yes. You did => null. The problem is elsewhere. See docs for decodeResource():

    Returns: The decoded bitmap, or null if the image could not be decoded.

    so you need to a) always check for that condition, b) check why exactly it happens with the data you try to decode.

提交回复
热议问题