Android official tutorial from zero opener (one)

Source: Internet
Author: User

Dizzy death, write ppt write to 11:30, I just want to quietly write code, write a woolen ppt, write finished also said no, let rewrite, head is big, elder brother now just want to do a coder only, now or fish, Man, don't say, can't first day digging pits not fill.

Getting Started

Building Your First APP

Creating an Android Project

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/54/48/wKiom1R93f2DmLA0AAFNot-yDHc809.jpg "title=" Adt-firstapp-setup.png "alt=" Wkiom1r93f2dmla0aafnot-ydhc809.jpg "/>

Create a project that can not be more familiar, from top to bottom is the app name, project name, package name, Minimum SDK version, highest version, use of the compiled version, app theme

Of course, it can be created with the command line.

Enter under tools/path

Android list targets

You can print out the available target SDK versions.

If you are creating a project, use:

Android Create Project--target <target-id>--name myfirstapp--path <path-to-workspace>/myfirstapp-- Activity mainactivity--package Com.example.myfirstapp


Running Your application very sleepy ...

This lesson is mainly about running apps on real machines and simulators, we'll first specify Sdkversion

<manifest xmlns:android= "Http://schemas.android.com/apk/res/android" ... > <uses-sdk android:minsdkversion = "8" android:targetsdkversion= "/>" ...</manifest>

And then say something about the directory structure of Android project

  • src/

  • Directory for your app ' s main source files. By default, it includes a Activity class that runs when your app is launched using the app icon.

  • res/

  • Contains several sub-directories for app resources. Here is just a few:

    • drawable-hdpi/

    • Directory for drawable objects (such as bitmaps), that is designed for high-density (hdpi) screens. Other drawable directories contain assets designed for other screens densities.

    • layout/

    • Directory for files that define your app's user interface.

    • values/

    • Directory for other various XML files, contain a collection of resources, such as string and color definitions.

src/

The app's source folder, which is the default, includes an activity that runs when you click on the app icon.

res/

Contains a number of app resources. These include:

drawable-hdpi/

A Directory of Drawable objects (such as bitmaps), designed for hdpi screens, and other drawable directories that contain resources designed for other screen densities

layout/

The user interface directory for the app.

values/

A directory of various other XML files that contains a collection of resources, such as string and color definitions.


The next step is how to run the app on a real machine.

    1. Load drivers for Android devices

    2. Turn on the phone's test mode

You can also use the command line to run

  1. Change directories to the root of your Android project and execute:

    Ant Debug
  2. Make sure the Android SDK platform-tools/ directory are included in your PATH environment variable, then execute:

    ADB install bin/myfirstapp-debug.apk
  3. On your device, locate myfirstactivity and open it.

That's how you build and run your Android app on a device! To-start developing, continue to the next lesson.

To run on the emulator:


Run on the Emulator

Whether you ' re using Eclipse or the command line, to run your app in the emulator you need to first create anandroid Virtu Al Device (AVD). An AVD are a device configuration for the Android emulator this allows you to model different devices.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

Figure 1. The AVD Manager showing a few virtual devices.

To create an AVD:

  1. Launch the Android Virtual Device Manager:

    1. In Eclipse, click Android Virtual Device Manager 650) this.width=650; "Src="/e/u261/themes/default/images/spacer.gif " Style= "Background:url ("/e/u261/lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= " Spacer.gif "/>from the toolbar.

    2. From the command line, change directories to and <sdk>/tools/ execute:

      Android AVD
  2. In the Android Virtual Device Manager Panel, click New.

  3. Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a skin (HVGA is default).

  4. Click Create AVD.

  5. Select the new AVD from the Android Virtual Device Manager and click Start.

  6. After the emulator boots up, unlock the emulator.

To run the app from Eclipse:

    1. Open one of your project's files and click Run 650) this.width=650; "Src="/e/u261/themes/default/images/spacer.g If "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" Spacer.gif "/> from the toolbar.

    2. In the Run as window, appears, select Android application and click OK.

Eclipse installs the app on your AVD and starts it.

Or to run your app from the command line:

  1. Change directories to the root of your Android project and execute:

    Ant Debug
  2. Make sure the Android SDK platform-tools/ directory are included in your PATH environment variable, then execute:

    ADB install bin/myfirstapp-debug.apk
  3. On the emulator, locate myfirstactivity and open it.

That's how to build and run your Android app on the emulator! To-start developing, continue to the next lesson.

Steal a lazy, paste directly ...

The AVD here means the simulator Android virtual device


This article is from "Jack's Footsteps" blog, make sure to keep this source http://jack326162646.blog.51cto.com/7640742/1585753

Android official tutorial from zero opener (one)

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.