Kotlin Android Fragment recyclerView and context issue
Move this code
recylerView_Main.layoutManager = LinearLayoutManager(context)
recylerView_Main.adapter = Mainadapter()
from onCreateView
to onActivityCreated
override onActivityCreated
and place the above code.
There are two things incorrect in your code :
You are trying to access
recyclerView
even before inflating the View.The context of a Fragment is null in onCreateView and is usable in between
onAttach
andonDetach