This article only does the study record, does not do the tutorial, therefore each point is simply the record. There are questions or suggestions can leave a message to discuss
First, the preparation of knowledge
Android four-tier architecture what's probably a bit of a look, we write Android programs, are based on the system to our API programming. And the system to the API, need to install the SDK to use (which I personally understand), so for programming convenience, we set up the eclipse environment, and then install the ADT plug-in, configure the SDK, with Eclipse programming.
Second, the environment construction
Configure the Java environment to download ECLIPSE,ADT,SDK. Java,eclipse,adt What, Baidu Tutorial cost a lot of time, then the configuration SDK, after installing ADT, he will automatically generate a directory of the SDK, the download of the SDK files to the directory. Just download the SDK there are only some of the most basic tools, the package containing the API is not installed, to download the installation itself (from Api3 to api20, all loaded up for several days, There is a android4.1 mobile phone, so I first android4.0 the corresponding API packaging, and then the programming used in this environment, the SDK download speed is very slow, in the system's Hosts file add some Google's IP will be faster.
Third, the first Android program
New project, choose android Application project, write the name, then choose the lowest program API, the expected API, the highest API, the lowest I chose Android4.0, the other did not change, all the way next. In fact, this is already a complete Android program, that is, we are very familiar with the Hello World program. Open the Eclipse Devices window and connect to the Android phone and see the phone in the devices window to indicate the connection was successful. Right-click the project, run as select Android application, then select the device (which is connected to the phone, or you can build your own Android virtual machine). You can then see the app on your phone, and the app is already installed on your phone.
Iv. How the Android program is launched
Android programs, which are actually Java programs. Our Java program is generally run a class,android is also the case, just a few more configuration files. The Android program will first find the Mainactivity.java file under SRC and then execute the file. In this class, there is a oncreat method, in fact, we have written before the main method is similar to the program is from here. Then the program through this oncreat method inside the Setcontentview, find the main activity layout file, this layout file, we see the Android program start, the first look at the appearance of the. So we have to arrange the initial interface of the program through the configuration of this layout file. This layout file, opened in the Res/layout directory, can be laid out through the visual interface of Eclipse, or it can be laid out by code.
V. Basic components of Android programs
Users see the Android program is an interface, and then click on something on the interface will pop up another interface. Android programs are made up of these interfaces, which are called activity, and there are controls on the activity, such as buttons, text boxes, and so on, which are called view.
Six, Android simple layout files and simple view
Layout file, the first thing to write is the layout, and now only learn the linear layout, that is, LinearLayout. For LinearLayout, indicate the layout direction, horizontal or vertical. Then is in the layout file to add some controls, such as text box TextView, the control's properties are many, the first is the ID, this can write not write, but generally is to write, because in the later program run, we want to get this view object, is to find through the ID. Then there is the width and height of the view, the location of the arrangement (this look at the layout of the arrangement), this situation, there are background color background, color, and display the text of what. These are the most basic attributes of the view.
Vii. Android Listener
In fact, this is the same as Java, but with the Andriod package inside the listener only. Basically there are four steps:
1. Get the object of the control to listen to, this can be used Findviewbyid method, this method is a view object, to be transformed downward into the object of the listening space class. All the controls are inherited from the view class.
2. Create the listener class to implement the appropriate listener interface.
3.new a Listener object.
4. Set the listener on the control, that is, let the listener just listen to the control.
--------------------------------------------------------------------------------------------------------------- ---------------------------------
Here, if there is some Java foundation, it should be an introduction to Android. The next step is to learn the usage of various layout,view and listeners, and so on, as well as some programming techniques.
Android Learning Notes