package Ġcom . hi ber us . open bank . mar vel . ui . main Activity Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . util . Log Ċ import Ġandroid . view . View Ċ import Ġandroidx . activity . view Models Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġandroidx . navigation . fragment . Nav Host Fragment Ċ import Ġandroidx . navigation . ui . setup With Nav Controller Ċ import Ġcom . hi ber us . open bank . mar vel . R Ċ import Ġcom . hi ber us . open bank . mar vel . databinding . Activity Main Binding Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity () Ġ{ ĊĠĠĠ Ġlateinit Ġvar Ġbinding : ĠActivity Main Binding ĊĠĠĠ Ġprivate Ġval Ġmain ViewModel : ĠMain ViewModel Ġby Ġview Models () ĊĠĠĠ Ġvar ĠTAG : ĠString ? Ġ= Ġ" MainActivity " ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠData Binding Util . set ContentView ( this , ĠR . layout . activity _ main ) ĊĊĊĠĠĠĠĠĠĠ Ġ// Click Ġback Ġin Ġmenu , Ġneeds Ġactivity Ġcomponents ĊĠĠĠĠĠĠĠ Ġmain ViewModel . menu Model . click Back Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠView . OnClickListener Ġ{ Ġfind Nav Controller ( R . id . nav _ host _ fragment ). navigate Up () Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . m vm Ġ= Ġmain ViewModel ĊĠĠĠĠĠĠĠ Ġbinding . menu M Ġ= Ġmain ViewModel . menu Model ĊĊĠĠĠĠĠĠĠ Ġ// bottomnavigation Ġview Ġconfig ĊĠĠĠĠĠĠĠ Ġval Ġnav Host Fragment Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsupport FragmentManager . find Fragment ById ( R . id . nav _ host _ fragment ) Ġas ĠNav Host Fragment ĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġnav Host Fragment . nav Controller ĊĠĠĠĠĠĠĠ Ġbinding . bottom Navigation View . setup With Nav Controller ( nav Controller ) ĊĊĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" main activity Ġcreated ") ĊĊĠĠĠ Ġ} ĊĊ Ċ }