As we all know, "Hello, World" is the first line of code written by programmers involved in software development, and it also marks the beginning of the development industry in related fields. This blog is also customary, from the most basic Android version of "Hello, World" start, create their own first Android project, write down their first line of Android code, to achieve their first Android app--helloandroid.
Here is the first introduction of the development environment used by bloggers. Desktop system for Windows 10 Home Edition 1709;ide for Google official Android Studio, Version is the latest 3.0, in addition to fully support the Kotlin language, and the previous version 2.3 changes are not very large, at least for the most basic Android development has no significant impact; Debug device is Avd,pixel XL, System version 8.0;JDK version is Oracle JDK 9.0.1.
The above environment installation process online There are many, in this inconvenient to repeat, Baidu Google a search is.
Below, begin to build your first project. First, point to your own Android Studio, as shown in:
Click "Start a new Android Studio project" To enter the project configuration interface:
"Application Name" is the name of the project we are going to build, we modified to "Helloandroid", "Company name" is the name of the corporation, there is no way to keep the default, Bo Major to "ustc.edu.cn", " Project location is the project's save path, which can be modified anywhere you want to save it. The following are the team C + + and Kotlin support, where we can not use, will remain the default unchecked. Then click on "Next":
Here is the choice of the target Android device type, we are the development of Android mobile device, so choose the default "phone and Tablet". The drop-down menu selects the minimum supported Android version, where we chose Android5.1. Then click on "Next":
Here is the interface to add activity, we can choose to add or not to add. Google has prepared a variety of templates for us to choose from, we can choose the appropriate template, on this basis to modify. If there is no suitable, or want to start from scratch, you can choose "Empty Activity", here, we choose this. Of course, if you don't add it here, you can click on the "Add no Activity" in the top left corner. Click "Next":
Here to configure our activity, from top to bottom, respectively, the name of the activity, where the default is "Mainactivity", the following default check is to create a new interface layout file, which is used to show the user to see the file, if the tick will see the following layout name, the default is " Activity_main ", the following options are also checked by default. Here we all follow the default. It is worth mentioning that the first letter of the activity name must be capitalized, layout name must all lowercase. Below, click "Finash", this time the Android studio started the new project configuration work, patiently wait for a moment, you can see the following interface, this time our new project is ready to build.
Next click: Res->layout->activity_main.xml, double-click this XML file, this layout file is what our app displays on the phone screen. The following changes it to:
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Cn.edu.ustc.helloandroid.MainActivity"> <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Hello world!"android:textsize= "22DP"/></LinearLayout>
by this time our first application software, Helloandroid, was finished. Click on the green triangle above or you can debug it. After clicking, select your device, the virtual device used here, the model number and the Android version above have been given, here no longer repeat. After the run, the interface looks like this:
Here, our task is basically finished. See you next time ヾ ( ̄▽ ̄) bye~bye~
hello,android--starts with the most basic Android development