Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Last active March 12, 2021 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatilShreyas/700491abfef1e6877800dc4917cb2c45 to your computer and use it in GitHub Desktop.
Save PatilShreyas/700491abfef1e6877800dc4917cb2c45 to your computer and use it in GitHub Desktop.
private val mAdapter = MyListAdapter() // 1️⃣
// OR private var mAdapter: MyListAdapter? = null 2️⃣
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// OR Initialize MyListAdapter everytime when View is created 2️⃣
// mAdapter = MyListAdapter(...)
binding.recyclerView.adapter = mAdapter
}
override fun onDestroyView() {
super.onDestroyView()
binding.recyclerView.adapter = null // 1️⃣
// OR mAdapter = null 2️⃣
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment