Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/ListFragment.kt Secret

Last active Mar 12, 2021
Embed
What would you like to do?
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