Start your first Android program

In my impression, the first program of each language and each platform seems to output Hello Word! It seems that Android is no exception, the first program displayed is Hello Word! In this article, I will tell you how to develop the first Android program. It's actually very simple.

1. Open our Android Studio:

If it is the first time to open it, it is basically this interface:

 It's not the first time I opened it, so it's not this interface, but another interface:

We can choose File-->new-->new Project, anyway, the next step is to enter the same interface:

 

 On the left side, we can choose the device type, such as TV, mobile phone, bracelet, etc., and on the right side, we can choose the home page template to be created. You can choose this template by yourself. Generally, there are login templates and map templates that are more commonly used, but the one I use the longest is the empty template, which is an empty interface, and then click next to enter the next step.

In this step, there are actually some general settings about the app:

 Enter the name of the interface in the Name column. Generally, the homepage is named MainActivity. Of course, as long as there is no special meaning, the name can be chosen casually, and then the Package name, which is chosen according to your own needs. Save location is to save the project by yourself. The path can be customized. It is best to create a special folder management project by yourself, so that it is not so easy to lose. In terms of Language, it mainly depends on the language you are learning, whether it is Java or Kotlin. Since I have been developing I use Java, so I always choose Java, and MiniMum SDK chooses the smallest api version. This needs to be determined according to the actual situation, mainly depending on the version of the target device that your app is running on, but now generally low-version apps There will be less, you can choose a moderate version. After all these are set, you can click Finish to complete the creation of this app.

2. After the app is created, it can actually be run directly. When we run it, we can use our mobile phone to connect to adb to run it. Of course, we can also use the virtual machine that comes with Android Studio to run it. I usually download a Yeshen virtual machine to run my program. Here you can prepare a night god simulator to run our own app.

The app code interface after successful creation:

 

We hold down Ctrl and click activity_main to enter the interface design interface: 

I have downloaded the Night God simulator, so I can run my app directly on the Night God:

 Select the running device, and then click the green play button to run the app directly, the effect is as follows:

 Well, this is the first Android program to run. If you don't understand, you can leave a message to communicate.

Guess you like

Origin blog.csdn.net/weixin_39882179/article/details/128545849