Once we start the Android Studio environment the main dialog appears:
We chose the option “Start a New Android Studio project”
Now a series of windows will appear to configure the project, the first dialog we must specify the Name of the application, the url of our company (which will be the name of the package that allocates for the source files), the location on the disk of our project And we must select to include the support for programming with the Kotlin language:
In the second dialog we proceed to specify the minimum version of Android where the application will be executed (we will leave version 4.0.3):
The third dialog specifies the basic skeleton of our application, we will select “Empty Activity”:
Finally the last dialog we have to indicate the name of the main window of the application (Activity Name) and other more data that we will see during the course (we will leave with the default names that proposes Android Studio):
We have finally created our first project in Android Studio configured to program with Kotlin and we can now see the Android Studio environment to encode the application:
Android Studio generates all the directories and basic files to start our project, we can see them on the left side of the development environment:
We will not do at this moment an analysis of the meaning and purpose of each of these sections and files generated, but as we move forward with this course we will be seeing in a punctual and profound way.
The visual interface of our Android program is stored in an XML file in the folder res, subfolder layout and the file is called activity_main.xml. In this folder we have created our first screen.
When selecting this file, Android Studio allows us to display the content in “Design” or “Text” (ie in design view or in code view):
As of version 2.2 of Android Studio we have the “blueprint” view that gives us a very useful simplified interface when we have complex screens that we will see later. We can only see the design view or “blueprint” by selecting one of the buttons that appear here:
Android Studio already inserted a control of type ConstraintLayout that allows to enter visual controls and to place them in relation to the edges of the window or relative to other controls (later we will analyze this layout)
We will see that we can modify all this file to suit the application that we want to develop.
Throughout this course we will see the objectives of each one of the sections that the Android Studio has to implement to implement the interface, to code in Kotlin the functionalities of the application, etc.
Before testing the application in the emulator of an Android device will proceed to make a small change to the interface that appears in the cell phone: delete the label that says “Hello World” (simply by selecting the mouse with the item and pressing the delete key, We can select it from either of the two “Design” or “blueprint” interfaces)
Verify that the Autoconnect icon is active:
From the “Palette” drag a “Button” to the center of the cell phone and in the “Properties” window with the “Button” selected, we will change the “text” property to the “Hello World” string:
To run the application press the green triangle or select from the options menu “Run -> Run app” and in this dialog proceed to leave the default emulator selected (Nexus 5X) selected and press the “OK” button (if it does not have No emulator can create one):
After a while the Android emulator will appear on the screen (the start of the emulator may take more than a minute), it is IMPORTANT to note that once the emulator has been started we should not close it every time we make changes to our application Or encode other applications, but we re-run the application with the changes and being the emulator running the time it takes until it appears our program in the emulator is very small.
When the emulator has finished loading, our application should appear:
Nothing happens if we press the button, this because we have not coded anything for that event.
How useful was this post?
Click on a star to rate it!
Average rating / 5. Vote count:
We are sorry that this post was not useful for you!
Let us improve this post!
Thanks for your feedback!