“Do not place Android context classes in static fields; this is a memory leak” - Lint Warning for static View

后端 未结 2 1165
猫巷女王i
猫巷女王i 2021-01-17 05:12

There are questions with a similar title, but them all about Context that you get in constructor.

There are RecyclerView with items and some other v

2条回答
  •  既然无缘
    2021-01-17 05:42

    You should decouple view (mPlayPauseButton) from that functionality to avoid leaks. To do this, you can implement a listener pattern. The easier way in that code could be passing a "listener" object as a parameter instead directly the view reference...

提交回复
热议问题