class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding
private lateinit var navController: NavController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
navController = Navigation.findNavController(this, R.id.bottom_nav_control)
setupWithNavController(binding.bottomNavigationView, navController)
}}
Here,private lateinit var binding: ActivityMainBinding not working?! i tried adding
build Features {view Binding true}
these code to enable binding on my build.but it didn't work
if you know any other answer comment here
CodePudding user response:
Refer to your comment, since you renamed your xml
to mainactivity.xml
. You can call it by using
MainactivityBinding
instead
ActivityMainBinding
CodePudding user response:
remove these line and add below one for activity
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
private lateinit var binding : ActivityMainBinding
binding = DataBindingUtil.setContentView(this,R.layout.your_layout)