Does anybody know a WORKING solution? None of the other threads helped.
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
binding.mainRecyclerView.layoutManager = LinearLayoutManager(this)
binding.mainRecyclerView.setHasFixedSize(true)
adapter = MainRecyclerAdapter(this, null)
binding.mainRecyclerView.adapter = MainRecyclerAdapter(this, null)
}
CodePudding user response:
Do this :
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.mainRecyclerView.layoutManager = LinearLayoutManager(this)
binding.mainRecyclerView.setHasFixedSize(true)
adapter = MainRecyclerAdapter(this, null)
binding.mainRecyclerView.adapter = MainRecyclerAdapter(this, null)
when you use View Binding , you must pass the root view to setContentView()
