• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Consolidating setContentView(R.layout.activity_main) with ViewBinding

Murphler

Lurker
I'm new to Android development and i'm trying to combine the functionality from 2 separate tutorials into one app.

One of them, which i've already implemented, simply uses setContentView(R.layout.activity_main) in order to provide the main activity for it's fragments. The second uses the below code


binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
setSupportActionBar(binding.toolbar)

What is the best way for me to go about combining these 2 different approaches so i don't end up creating errors in the code already implemented

Thanks
 
Back
Top Bottom