HelloWorld for android

Source: Internet
Author: User

I just joined google + yesterday. A friend who needs an invitation code left a mailbox. I will send it to you!

1. Create an android project and enter the properties of the project, as shown in.

2. Click Finish, as shown in.

3. You do not need to write any code. Run it directly to check the effect. Configure the always-running environment first, as shown in the system

Click run below to see that avd is starting, as shown in figure

4. the startup is successful. The interface is as follows. Unlock the following interface and you will be able to see helloWorld immediately.

7 HelloWorld Interface

Program Analysis:

1. Each Activity requires a class to inherit from. Activity can be understood as an Application Scenario. If you think of it as a web page, it is a page. You can jump between multiple activities, just as the webpage jumps to each other. You only need to set Intent, and do not need GetIntent. GetIntent is what the system does. When the system receives your Intent, it will automatically generate the class object instance of the page you want to jump to, and automatically callback the class Oncreate method, you only need to write down the UI initialization of your page in the Oncreate method. For example, the above program only has one Activity, that is, the activity_Main class and public class activity_Main extends Activity {
/** Called when the activity is first created .*/
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main); // you can use main. xml to set the activity layout.
}

The main. xml Code is as follows: indicates that there is only one text box in the interface <TextView>

<? Xml version = "1.0" encoding = "UTF-8"?>
Android: orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
>
<TextView
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/hello"
/>
</LinearLayout>

}

2 AndroidManifest. xml is a required file in every android program. It is located in the root directory of the application and describes global data in the package, including components exposed in the package (activities, services, and so on), their respective implementation classes, various data and startup locations that can be processed. The code in this example is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?>
Package = "com. fly. HelloWorld"
Android: versionCode = "1"
Android: versionName = "1.0" type = "codeph" text = "/codeph">
<Uses-sdk android: minSdkVersion = "8"/>

<Application android: icon = "@ drawable/icon" android: label = "@ string/app_name">
<Activity android: name = ". activity_Main"
Android: label = "@ string/app_name"> // The first started activity
<Intent-filter>
<Action android: name = "android. intent. action. MAIN"/>
<Category android: name = "android. intent. category. LAUNCHER"/>
</Intent-filter>
</Activity>

</Application>
</Manifest>

 

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.