android--starting from Hellowworld

Source: Internet
Author: User

1: The establishment of the Android project

Under the premise that the Android development environment is set up (the building of the Android development environment will be in the post-log). Open Eclipse and Execute file--new--android application project into the interface shown in 1:

Figure 1

Sub-Menu Description:

Application Name: The name of the app, which is the name of the app you want to develop.

Project Name:eclipse automatically names the name of project name Sing Woo application name.

Package Name: The names of the packages, which are the locations of the. Java files in the project.

Minimum Required SDK: The least supported SDK version of the program. With the minimum version set to the standard, the operating system will reject the app installation on devices with a system version that is lower than the standard.

Target version SDK:SDK should be designed to run to that API level, in most cases the target version is the latest released version of Android (the target version will be reduced in actual development based on actual needs).

Compile with: The version of the SDK compiled by the program is generally the same as the target version, which does not appear in the manifest file. The minimum and target versions of the SDK are notified to the operating system, and the compiled version of the SDK is the private information between us and the compiler does not appear in the manifest file.

Theme: The principal Theme is the body style used to set the UI interface. For a detailed introduction to theme, see: http://blog.csdn.net/feng88724/article/details/6457431

Fill in the project name "Hellow" and the package name "Com.shanzhishi.hellow" (The package name is filled in accordance with the domain name inversion of the roll). Choose the lowest SDK version for API 8 target version: 16 compiled version: 16. Then click Next to enter the interface shown in Figure two:

Figure 2

Clear the option to create a custom launch icon (created custom launcher icon) that has been checked, because the Hellowworld application only needs to use the default boot icon. Then continue to click Next, the following will let you choose the type of anctvity, according to the default standard is to select the blank activity. After that, the bottom next goes into the interface shown in 3, which allows us to name the activity and layout, where the layout name system automatically reverses the name of the activity and turns it into lowercase. Note that the first letter of activity name needs to be capitalized.

Figure 3

Clicking Finish will enter Eclipse's workspace, and it should be explained that if you select a different version of the SDK and its target version, the corresponding Compatibility Pack (APPCOMPAT_V7) will pop up in the workspace created between them. It is now possible to say that an Android project has been established.

2: Introduction to the work zone

Figure 4

The leftmost is the package explore view, which allows you to manage the relevant files for your project:

The main documents and the contents are described as follows;

1.SRC: Store all the *.java source programs.

2.gen: Save path for automatically generated code file for ADT plug-in, R.java will save all resource IDs.

3.assets: Can hold the project some large resource files, such as: pictures, music, fonts and so on.

4.res: Can store all the resource files in the project, for example: Pictures (*.png, *.jpg), text, etc.

5.RES/DRAWABLE-HDPI: Save a high-resolution picture resource, you can use Resources.getdrawable (ID) to get the resource type.

6.RES/DRAWABLE-LDPI: Save a low-resolution picture resource, you can use Resources.getdrawable (ID) to get the resource type.

7.RES/DRAWABLE-MDPI: Save a medium-resolution picture resource, you can use Resources.getdrawable (ID) to get the resource type.

8.res/layout: Store all layout files, mainly for arranging different display components, to read this configuration in the Android program.

9.res/values: The information that holds some resource file, is used to read the text resource, in this folder has some convention file name.

The middle area is the code editing area (editor). For ease of development, Eclipse opens the Activity_hellow layout file by default, which can be toggled in areas of code and views.

The right-most task list is: task lists (special introductions will be made later)

Outline represents: The main class method variables in the project, and some of the icons and their representations are as follows:

Method of representing solid
Hollow Representative Properties
A green circle indicates public
A yellow diamond indicates protection protect
The Red Square indicates private
The blue triangle indicates default

3. The layout file is Activity_hellow.xml file detailed

<Relativelayout

xmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:paddingbottom= "@dimen/activity_vertical_margin"Android:paddingleft= "@dimen/activity_horizontal_margin"Android:paddingright= "@dimen/activity_horizontal_margin"Android:paddingtop= "@dimen/activity_vertical_margin"Tools:context= "Com.shanzhishi.hellow.HellowActivity" > <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "@string/hello_world" /></Relativelayout>

The meaning of our line is as follows:

This section of the question is an. xml file that completes the layout of the Android interface.

<relativelayout:xml a common way of layout. Relativelayout is a relative layout, where the position of the control is calculated by relative position, where the latter depends on the base position of the previous control, which is the most common and flexible layout of the layout.

xmlns:android= the phrase "Http://schemas.android.com/apk/res/android" declares the XML namespace. XMLS means "XML namespace". The colon is followed by an alias to the reference. Schemas is one of the two kinds of constraint files in XML documents. Specifies what elements (tags) are in the XML, what attributes the element has, and the relationships between the elements. From an object-oriented perspective, it can be understood as a constraint to the XML document of the schemas file or as a template.

Xmlns:tools= the meaning of the phrase "Http://schemas.android.com/tools" (http://blog.csdn.net/zhengdan66/article/details/46960985)

Android:layout_width= the phrase "match_parent" means that the width of the layout is consistent with the parent layout

android:layout_height= the phrase "match_parent" means that the height of the layout is consistent with the parent layout

android:paddingbotton= "@dimen/activity_vertical_margin" This means that in your values folder below the Dimens file has a name called Activity_ Vertical_margin, this entry is the value of your android:paddingbottom.

The same is true of android:paddingright/left/top.

Here's another label <textview this tag is used to display text messages.

Android:layout_width= "Wrap_content" means the width of the view is automatically adapted.

Android:layout_height= "Wrap_content" indicates that the height of the view is automatically adjusted according to the content.

android:text= "@string/hellow_world" means that the content shown here is the corresponding name= "Hellow_world" in the Res/string/strings.xml file, that is, Hello World !

<?XML version= "1.0" encoding= "Utf-8"?><Resources>    <stringname= "App_name">Hellow</string>    <stringname= "Hello_world">Hello world!</string>    <stringname= "Action_settings">Settings</string></Resources>

The code snippet above is the contents of the Strings.xml file.

Introduction to the 4.hellowactivity.java file. Hellowactivity.java file describes the establishment of activity and other methods, the detailed introduction will be used in a special section to introduce the analysis.

5. Run, first open the Android virtual machine or connect the real machine to the computer click on the run as--android application running in the project as shown in effect 5

At this point, the first Android program Hellow World is finished, the above content there are many not mentioned in the details, will be in the follow-up study to do further study.

android--starting from Hellowworld

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.