您的位置:首页 > 移动开发 > Android开发

Getting Started Android

2015-08-31 22:55 435 查看
Getting Started

Welcome to Training for Android developers. Here you’ll find sets of lessons within classes that describe how to accomplish a specific task with code samples you can re-use in your app.

Classes are organized into several groups you can see at the top-level of the left navigation

译文1

欢迎来到为Android开发者培训,在这里你会发现一组带类课程描述如何去完成用代码样本去完成特定任务,你可重新使用在您的应用程序。
类被组织成若干组,您可以在左导航的顶层看到


Build Your first App

After you’ve installed Android SDK , start with this class to learn the basics about Android app development

构建你的第一个应用程序
在您安装Android SDK,开始与这类学习Android应用程序开发的基础知识


Createing an Android Project

An Android project contains all the files that comprise the source code for

your Android app.

This lesson shows how to create a new project either using Android Studio or using the SDK tools from a command line.

Note: You should already have the Android SDK installed, and if you’re

using Android Studio,you should also have Android Studio installed. If

you don’t have these, following the guide to Installing the Android SDK

This lesson teaches you to

Create a Project with Android Studio

Create a Project with Command Line Tools

You should also read

Managing Projects

创建一个Android项目
一个安卓项目包含了所有的文件包括Android源代码
本课介绍Android Studio或在命令行使用SDK工具创建一个新工程
注意:你应该已经安装Android SDK,如果你使用Android Studio
还应该有Android Studio的安装,如果你还没有这些,在开始这一课之前,下面有Android SDK指南

本节课将教会你
用Android Studio创建一个项目
在命令行工具下创建一个项目
你应该也阅读
管理项目


Create a Project with Android Studio

1,In Android Studio, create a new project

If you don’t have a project opened,in the Welcome screen,click New Project

If you have a project opened,from the file menu,select New Project.

2.Under Configure your new project fill in the fields as shown in figure 1 and Click Next

It will probably be easier to follow these lesson if you use same

values as shown.

Application Name is app name that appears to users. For this

project ,use “My First App”.

Company domain provides a qualifier that will be appened to the package name;Android Studio will remember this qualifier for each new project you create.

Package Name if the fully qualified name for the project (following the same rules as those for naming packages in Java programming language). Your package in the Java programming langauage)Your package name must be unique across all packages installed on the Android system. You can Edit this value indepently from the application name or the company domain.

Under Select form is the directory on your system run on, check

the box for Phone and Tablet

For Minimum SDK select API 8: Android 2.2(Froyo)

The Minimum Required SDK is the earliest version of Android that your app supports in,indicated using the API level. To support as many devices as possible,you should set this to the lowest version available that allows your app to provide its core feature set. If any

feature of your app is possible only on newer versions of Android and it’s not critical to the app’s core feature set , you can enable the feature only when running on the versions that support it (as discussed in Supporting Different Platform Versions)

用Android Studio建一个项目
1.在Android Studio,创建一个新工程
如果你还没有打开一个项目,再欢迎屏幕上,点击新建项目
如果你打开了一个项目,从文件菜单,选择新建项目
2.在配置你的新项目下,如图1所示,填写区域,然后单击下一步
如果你使用相同的值如图所示,它将上下面的这些课程中很容易
应用程序名称
应用程序名称是用户的应用程序名称。对于这个项目,使用“我的第一个应用程序。”
公司域提供一个限定符,将被添加到包的名称;Android Studio
将会记住这个限定符,为每一个新建的项目
包的名称是项目的完全限定名(在Java程序语言中遵循相同的包命名规则),你的包名必须在Android系统上所有安装包时唯一的,你可以单独从应用程序名称或改公司域中单独编辑该值
项目的位置是保存项目文件的系统目录
最小SDK 选择API8 Android 2.2(Froyo)
所需的最小SDK是最早版本的Android应用程序的支持,使API级别显示。尽可能支持多的设备,你应该设置这个为最低版本,让你的应用程序提供喝核心功能集。如果你的应用程序任何功能是可能的,只有在新的版本Android,它不是关键的应用程序的核心功能集,你可以启动该功能仅当支持它(如讨论不同的平台版本),


5.Leave all of the other option(TV, Wear,Glass) unchecked and click Next.

6.Under Add an activity to , select Blank Activity and click Next.

7.Under Choose options for you new file,change the Activity Name to MyActivity. The Layout Name changes to activity_my and the Title to MyActivity. The Menu Resource Name is menu_my.

8.Click the Finish button to create the project

Your Android project is now basic “Hello World” app that contains some default files. Take a moment review the most important of these

5.放弃其他所有选项(TV,Wear,Glass)未选中,然后单击下一步
6.在添加Activity到模版,选择空白Activity,然后单击下一步
7.在选择您的新文件选项,更改Activity名称为MyActivity,布局名称改为activity_my和标题MyAcitivy,菜单资源名为menu_my
8.单击Finish按钮去创建项目
你的Android项目时一个基本的“Hello World“应用程序,包含一些默认文件,花一些时间回顾这些事最重要的。


Create a Project with Command Line Tools

If you’re not using the Android Studio ,you can instead your project using SDK Tools from command line

1.Change directories into the Android SDK’s sdk/path

2.Execute

tools/android list targets


This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find the platform against which you want to compile your app. Make a note of the target ID. We recommend that you select the highest version possible. You can still build your app to support older versions, but setting the build target to the latest version allows you to optimize your app for the latest devices.

If you don’t see any targets listed, you need to install some using the Android SDK Manager tool. See Adding SDK Packages.

用命令行工具创建一个项目
如果你没有使用Android Studio IDE,你可以使用在命令行上使用SDKgo工具,改变目录到Android SDK的路径
执行下面的语句
tools/android list targets
这将列出了可用的Android平台,你已经下载了SDK,找到你想编译的应用程序,记下目标编号。我们建议选择最高的版本。您仍然可以建立您的应用程序,以支持旧版本,但设置的最新版本的构建目标,让您为您的最新设备优化你的应用程序。如果你没有看到任何目标列表,你需要安装一些Androi SDK管理工具,看到添加SDK包


Execute

android create project –target –name MyFirstApp \

–path /MyFirstApp –activity MyActivity \

–package com.example.myfirstapp

Replace with an ID from the list of targets (from the previous step) and replace with the location in which you want to save
4000
your Android projects.

Tip: Add the platform-tools/ as well as the tools/ directory to your PATH environment variable.

Your Android project is now a basic “Hello World” app that contains some default files. To run the app, continue to the next lesson.

执行:
android create project --target <target-id> --name MyFirstApp \
--path <path-to-workspace>/MyFirstApp --activity MyActivity \
--package com.example.myfirstapp

替换 从目标列表的<target -id> 从先前的步骤。替换<path-to-workspace>的标识,以在您希望保存您的Android项目的位置

提示:添加平台工/工具/目录到您的环境变量
你的Android项目现在是基本的“Hello World“
包含一些默认文件。要运行该应用程序,继续下一个课程。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 翻译