[Lushengduan] 01. Build an Android App development environment and write a program HelloWorld and lushengduan android

Source: Internet
Author: User

[Lushengduan] 01. Build an Android App development environment and write a program HelloWorld and lushengduan android

1. Build a Development Environment

1. JDK Environment Variables

Download JDK

Link: http://pan.baidu.com/s/1gen1o9l password: 8fko

Choose computer> Properties> advanced system Settings> environment variables to create a JAVA_HOME system environment variable.

C:\Program Files\Java\jdk1.7.0_80

Create a CLASSPATH system environment variable

.;%JAVA_HOME%lib;%JAVA_HOME%lib\tools.jar;

Append the value to the Path of the system environment variable.

;%JAVA_HOME%/bin;C:\Program Files\Java\jre7\bin

 

2. Install Android Studio

Link: http://pan.baidu.com/s/1mgRC7Wk password: mqn8

After the installation is complete, open Android Studio. Select the first one for Studio configuration. In this article, select the second one.

Next, follow the prompts to download and update the SDK online. After the SDK is installed, click "Finish ".

 

2. Compile the program HelloWorld

Open Android Studio and choose Start a new Android Studio project"

Change the program name to HelloWorld, and keep the default value in the second line (it is best to customize it here to avoid repeated package names with others)

Select "Phone and Tablet", and then select the SDK version. Here we select "4.0.3". Currently, mobile phones with Versions later than 4.0 are above 90%, so they are compatible with most devices.

Select "Add No Activity". We plan to write a HelloWorldActivity by ourselves. Instead of using the default Activity, click "Finish"

This step downloads some necessary things online. Please wait a moment to enter the main interface of Studio.

 

Now, we can start to write our HelloWorld. to present an interface that can be seen on a mobile phone, we must write a class that inherits from the Activity. The class name is HelloWorldActivity; in the java directory, right-click the content in the red box and choose New -- Java Class to create a New Class.

Input Class Name

Click "OK" and enter the following code in the HelloWorldActivity class:

package com.example.lushengduan.helloworld;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;/** * Created by Lushengduan on 2016/3/4. */public class HelloWorldActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        TextView textView = new TextView(this);        textView.setText("HelloWorld!");        setContentView(textView);    }}

Open AndroidManifest. xml and change its content to the following code:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.lushengduan.helloworld">    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:supportsRtl="true"        android:theme="@style/AppTheme">        <activity            android:name=".HelloWorldActivity">            <intent-filter>                <action android:name="android.intent.action.MAIN"/>                <category android:name="android.intent.category.LAUNCHER"/>            </intent-filter>        </activity>    </application></manifest>

Create an Android simulator or insert a mobile phone. Click Run -- "Run app" on the menu bar to Run the program. The running result is as follows:

So far, our HelloWorld application has been completed !!

 

Related Article

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.