package Ġnet . sy ari hu . android . sample . view model Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . lifecycle . ViewModel Providers Ċ import Ġnet . sy ari hu . android . sample . view model . databinding . Activity Main Binding Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity () Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠSample ViewModel ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Providers . of ( this ). get ( Sample ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ ĠData Binding Util . set ContentView < Activity Main Binding >( this , ĠR . layout . activity _ main ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel Ġ= Ġthis @ MainActivity . viewModel ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ