Ġpackage Ġcom . example . tod olist Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . content . Intent Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . navigation . Nav Controller Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġandroidx . navigation . fragment . Nav Host Fragment Ċ import Ġandroidx . navigation . ui . AppBar Configuration Ċ import Ġandroidx . navigation . ui . setup ActionBar With Nav Controller Ċ import Ġcom . example . tod olist . databinding . MainActivity Binding ĊĊ Ġclass ĠTask Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġlateinit Ġvar Ġbinding : ĠMainActivity Binding ĊĠĠĠ Ġlateinit Ġvar Ġapp Bar Configuration : ĠApp Bar Configuration ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠMainActivity Binding . inflate ( layout Inflater ) ĊĠĠĠĠĠĠĠ Ġset Support ActionBar ( binding . toolbar ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( binding . root ) ĊĊĠĠĠĠĠĠĠ Ġ// adding Ġnav Ġconfiguration ĊĠĠĠĠĠĠĠ Ġval Ġnav Host : ĠNav Host Fragment Ġ= Ġsupport FragmentManager ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. find Fragment ById ( R . id . nav _ host _ fragment ) Ġas ĠNav Host Fragment ? Ġ?: Ġreturn ĊĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġnav Host . nav Controller ĊĊĠĠĠĠĠĠĠ Ġapp Bar Configuration Ġ= ĠApp Bar Configuration ( set Of ( R . id . home _ dest ), Ġnull ) ĊĠĠĠĠĠĠĠ Ġsetup ActionBar With Nav Controller ( nav Controller , Ġapp Bar Configuration ) ĊĠĠĠ Ġ} ĊĊĠĠĠĠ Ġoverride Ġfun Ġon Support Navigate Up (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠĠ Ġreturn Ġfind Nav Controller ( R . id . nav _ host _ fragment ). navigate Up () Ġ|| Ġsuper . on Support Navigate Up () ĊĠĠĠĠ Ġ} Ċ } Ċ Ċ const Ġval ĠADD _ EDIT _ RESULT _ OK Ġ= ĠActivity . RESULT _ FIRST _ USER Ġ+ Ġ 1 Ċ const Ġval ĠDELETE _ RESULT _ OK Ġ= ĠActivity . RESULT _ FIRST _ USER Ġ+ Ġ 2 Ċ const Ġval ĠEDIT _ RESULT _ OK Ġ= ĠActivity . RESULT _ FIRST _ USER Ġ+ Ġ 3 ĊĊ