package Ġnu ud ay . android . sample . fragment . behavior Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . lifecycle . ViewModel Providers Ċ import Ġnu ud ay . android . bdc . fragments . behavior . Fragment Behaviour Ċ import Ġnu ud ay . android . sample . databinding . Main Fragment Binding Ċ import Ġnu ud ay . android . sample . fragment . Main ViewModel ĊĊ Ċ class ĠControl Input Done Action Fragment Behavior ( ĊĠĠĠ Ġprivate Ġval Ġfragment : ĠFragment Ċ ) Ġ: ĠFragment Behaviour Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġval Ġmain Binding Ġ= ĠData Binding Util . get Binding < Main Fragment Binding >( view ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠNullPointerException (" Not Ġcorrect Ġbinding ") ĊĊĠĠĠĠĠĠĠ Ġval ĠviewModel Ġ= ĠViewModel Providers . of ( fragment ). get ( Main ViewModel :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġmain Binding . todo Text . setOn Editor ActionListener Ġ{ Ġ_, Ġ_, Ġ_ Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . add Todo () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ } Ċ