package Ġnet . grand cent rix . android . formatted _ text . sample Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġnet . grand cent rix . android . formatted _ text . Formatted Text Ċ import Ġnet . grand cent rix . android . formatted _ text . sample . databinding . Activity View Binding Binding Ċ Ċ /** Ċ Ġ* ĠSample Ġactivity Ġwhich Ġshows Ġthe Ġwork Ġbetween Ġ[ Formatted Text ], Ġ[ Fallback Value ], Ġactivity , Ġfragment Ġand Ġview Ġmodel . Ċ Ġ*/ Ċ class ĠView Binding Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġprivate Ġval ĠviewModel Ġ= ĠMy Awesome ViewModel () ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠActivity View Binding Binding ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠActivity View Binding Binding . inflate ( layout Inflater ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( binding . root ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġnot Ġformatted Ġtext ĊĠĠĠĠĠĠĠ Ġbinding . not Formatted . text Ġ= ĠviewModel . not Formatted . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġ// Ġformatted Ġtext ĊĠĠĠĠĠĠĠ Ġbinding . formatted Number . text Ġ= ĠviewModel . formatted Number . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġbinding . formatted Number With Fallback . text Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . formatted Number With Fallback . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġbinding . formatted Null Number With Fallback . text Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . formatted Null Number With Fallback . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġ// Ġfallback ĊĠĠĠĠĠĠĠ Ġbinding . value With Fallback . text Ġ= ĠviewModel . value With Fallback . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġbinding . null Value With Fallback . text Ġ= ĠviewModel . null Value With Fallback . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġ// Ġquantity ĊĠĠĠĠĠĠĠ Ġbinding . quantity Value One . text Ġ= ĠviewModel . quantity One . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġbinding . quantity Value Many . text Ġ= ĠviewModel . quantity Many . resolve String ( this ) ĊĠĠĠĠĠĠĠ Ġbinding . quantity Value With Fallback . text Ġ= ĠviewModel . quantity With Fallback . resolve String ( this ) ĊĠĠĠ Ġ} Ċ }