‫Welcome back.
‫In this video we're going to learn how to create the greetings app.
‫This application will review all the views that we learned before.
‫Open the activity underscore Mainpage.xaml file.
‫And here I need to start with the text view.
‫This is just a title.
‫The width Matchparent the height wrap content the text.
‫Welcome to our app.
‫The size would be 28 SP and the gravity which is center.
‫This sets the text in the middle of the screen.
‫Then I need to select this text view and infer the constraints.
‫You can drag and drop it below 24 dpi.
‫It's good margin top.
‫Then I need to define another view which is an edit text with matchparent the height wrap content margin
‫left 16 dpi and margin right 16 dpi.
‫Then I need to display a hint.
‫Please enter your name.
‫I'll drag and drop this edit text below the text view and add the constraints.
‫You can drag and drop this blue circle and the drag and drop it below, which is the space 128 128 dpi
‫from the text view and you can infer the constraints like this.
‫Or you can click on this Infer Constraints button in order to infer the other constraints.
‫Later on, we'll talk about the constraints in deep, deep details in the constraint layout lesson.
‫Then I need to create a button wrap content, wrap content and the text this say hello.
‫Drag and drop this button.
‫Infer the constraints like this and click on this.
‫Add the horizontal constraints or you can type these attributes manually.
‫Then I need to create an image view.
‫This image view will display a logo for Java or Kotlin.
‫So I'll copy this logos.
‫And by the way you can get all of these resources and assets from the resources folder under each section.
‫So inside the resources folder the drawable folder paste these two images.
‫These are the logos.
‫Then inside this image view, I'll set it to 100 DPI, 200 dpi, and this is my image view in further
‫constraints.
‫And you can remove this constraint.
‫If you want control and left mouse you can remove it.
‫You can add here your constraint or you need to specify its height as 200 dpi.
‫This is good.
‫Till now we have an image view a button, edit text and text view.
‫I'll add another edit text before the button.
‫So edit text wrap content wrap content ID, Java or Kotlin edit text and the hint will be what language
‫you prefer Java or Kotlin?
‫Then move this edit text below the first edit text and link it with the edit text of the name, and
‫link it with the parent, and here link it with the right side of the parent.
‫Also, you can drag and drop it, or you can just click this Infer constraint button.
‫Okay, let me go to the main activity and start declaring the views here late.
‫Initiate var the image view the edit text and it's named as name edit text and late initiate var language
‫edit text.
‫It's of type edit text.
‫Late initiate var the text view.
‫And late.
‫Initiate var the bot.
‫All the classes should be imported correctly in the import under the package and before the class.
‫Now let's initialize these widgets or the views widgets and the views are the same.
‫Okay, I start with the image view equals to find view by id or ID, dot image view, edit text or language
‫edit text equal find view by ID or ID Java or Kotlin.
‫Edit text name.
‫Edit text equals to find view by id or ID dot edit text and let me see if I click on this.
‫The ID of it is edit text three.
‫Make sure that you specify IDs to simply memorize them.
‫Button equals to findviewbyid r.id dot.
‫But.
‫And we still have the text view equals to find view by id r.id dot text view go back to Text View two.
‫Okay, we declared and initialized our widgets.
‫Now let me use these widgets in order to add interactions.
‫When the user clicks on the submit button, I need to use the button dot set on click listener and inside
‫this click listener I need to specify a lambda expression.
‫Then I need to get the first text entered by the user, which is the name.
‫Then we'll move to the language specified by the user.
‫Here I start with var name or username equals to edit text name, edit text dot text dot toString.
‫This is the attribute or the function that allows us to get the name from the edit text.
‫Then the same way language selected equals to language edit text dot text dot toString.
‫I need to greet the user and say hello to the user.
‫Here I'll use a toast message dot.
‫Make text this which is the context of this activity.
‫The message is hello.
‫And here I need to specify the user name of the user that it is entered here in the edit text.
‫The third parameter is toast dot length long dot show message.
‫Okay, then we need to display Java or Kotlin logo in the image view.
‫If the language selected equals to Java, then we need to use the image view dot set image resource
‫r dot Roble dot Java logo.
‫Otherwise we need to use the image view dot set image resource to r dot drawable dot Kotlin logo.
‫If the user enters Java, then go and display Java logo.
‫Otherwise go and display the Kotlin logo.
‫Save the project and run.
‫This is our application here I'll enter my name Jack.
‫For example, the language you prefer Java or Kotlin I prefer Java.
‫Then click on say hello, hello Jack and the image of Java is displayed.
‫Let me use the preferred language as Kotlin.
‫Say hello.
‫The Kotlin image is displayed and hello Jack message is displayed.
‫So congratulations guys!
‫We reviewed all the views that we learned before in the previous lessons in this amazing application.