‫The second step is to declare and initialize the views that we created in this layout file.
‫For that move to main activity file, and in Android, declaring and initializing views involves defining
‫variables to reference UI elements, which are the views in your app's layout, XML files, and initializing
‫these variables with the corresponding views from the XML layout.
‫Let's start with the declaring the variables and the widgets.
‫And as mentioned before, in the previous lessons, you declare variables to hold references to the
‫views you want to interact with.
‫These variables are typically declared as properties in your activity or fragment class.
‫You should declare these variables at the class level so they can be accessed throughout the entire
‫class.
‫I'll start with late initiate var my text view type text view and I'll name it as title Text view in
‫order to distinguish it from the result text view.
‫Also we have result text view.
‫It's of type text view.
‫We have the edit text.
‫It's of type edit text and we have button convert button.
‫Late initiate is a keyword in Kotlin that is used to declare a Non-nullable property or variable that
‫will be initialized at a later time.
‫It's commonly used when you want to indicate that a property will have a value assigned to it before
‫you try to access its value, thus avoiding nullability checks and potential null pointer exceptions.
‫You must ensure that the late initiate variable is initialized with a value before you attempt to access
‫its value.
‫Thus, we need to move to the Oncreate method and start the initialization phase.
‫So after declaring the variables you need to initialize them by finding the corresponding views from
‫your layout XML file.
‫This is typically done in the Oncreate method of your activity or Oncreate view method of your fragment.
‫Later on, we're going to learn about fragments in the next sections, but for now we need to use Findviewbyid
‫method to find the views by their IDs in the Oncreate method.
‫Here I start with title text view equals.
‫To find the view by id or id dot text view result text equals findviewbyid r.id dot result text edit
‫text equals to find view by id r.id dot edit text.
‫And we have convert button equals to find view by id r.id dot convert button.
‫This is how we declare the variables and the widgets.
‫How we initialize the widgets in the Oncreate method.