




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
本方法适用于Android SDK 2.1环境下的程序开发安装JDK 在下载JDK并安装。 在“系统属性”的“高级”选项卡中点击“环境变量”,然后添加如下系统环境变量:1. 在PATH环境变量后追加 JDK安装路径中的bin路径,本机为:C:Program FilesJavajdk1.6.0_18bin2. 新建CLASSPATH环境变量或在CLASSPATH环境变量后追加JDK安装路径中的lib路径和demo路径,本机为:C:Program FilesJavajdk1.6.0_18demo;C:Program FilesJavajdk1.6.0_18lib安装Eclipse 在下载Eclipse IDE for Java Developers的Windows 32bit版本。 下载完成后解压即可使用。安装Android SDK OR 离线安装 在Android Developers下载android-sdk_r05-windows.zip,下载完成后解压到任意路径。 运行SDK Setup.exe,点击Available Packages,如果没有出现可安装的包请点击Settings,选中Misc中的Force https:/.这项,再点击Available Packages 。 选择希望安装的SDK及其文档或者其它包,点击Installation Selected、Accept All、Install Accepted,开始下载安装所选包 添加SDK安装目录中的tools文件夹路径至系统PATH环境变量,本机为:C:Androidandroid-sdk-windowstools关于离线安装用上面方法更新的时候速度很慢。更要等很久。所以我们可以直接把那些包下载下来安装。地址就是/androi . 2.0_r01-windows.zip/androi . 2.1_r01-windows.zip/androi . -1.1_r1-windows.zip/androi . 1.5_r03-windows.zip/androi . 1.6_r02-windows.zip/androi . ver_r03-windows.zip/androi . ogle_apis-6_r01.zip/androi . ogle_apis-5_r01.zip/androi . ogle_apis-4_r02.zip/androi . ogle_apis-7_r01.zip下完之后,名字以android的,解压到platforms里面;以google_apis开头的,解压到addons里面。usb驱动的,直接解压到根目录。安装Eclipse插件 ADT Start Eclipse, then select Help Install New Software. In the Available Software dialog, click Add. In the Add Site dialog that appears, enter a name for the remote site (for example, Android Plugin) in the Name field.In the Location field, enter this URL:/android/eclipse/如果无法通过上面的地址获得插件,可将https替换为http。(https is preferred for security reasons) Back in the Available Software view, you should now see Developer Tools added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next. In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish. Restart Eclipse.配置ADT在Eclipse中: 选择Window Preferences. 在左边的面板选择Android,然后在右侧点击Browse.并选中SDK路径,本机为:C:Androidandroid-sdk-windows 点击Apply、OK。配置完成。创建AVD为使Android应用程序可以在模拟器上运行,必须创建AVD。 在Eclipse中。选择Windows Android SDK and AVD Manager 点击左侧面板的Virtual Devices,在右侧点击New 填入Name,选择Target的API,SD Card大小任意,Skin随便选,Hardware目前保持默认值 点击Create AVD即可完成创建AVDCreate a New Android ProjectAfter youve created an AVD, the next step is to start a new Android project in Eclipse.1. From Eclipse, select File New Project.If the ADT Plugin for Eclipse has been successfully installed, the resulting dialog should have a folder labeled Android which should contain Android Project. (After you create one or more Android projects, an entry for Android XML File will also be available.)2. Select Android Project and click Next.3. Fill in the project details with the following values:o Project name: HelloAndroido Application name: Hello, Androido Package name: com.example.helloandroid (or your own private namespace)o Create Activity: HelloAndroido Min SDK Version: 7Click Finish.Here is a description of each field:Project NameThis is the Eclipse Project name the name of the directory that will contain the project files.Application NameThis is the human-readable title for your application the name that will appear on the Android device.Package NameThis is the package namespace (following the same rules as for packages in the Java programming language) that you want all your source code to reside under. This also sets the package name under which the stub Activity will be generated.Your package name must be unique across all packages installed on the Android system; for this reason, its very important to use a standard domain-style package for your applications. The example above uses the com.example namespace, which is a namespace reserved for example documentation when you develop your own applications, you should use a namespace thats appropriate to your organization or entity.Create ActivityThis is the name for the class stub that will be generated by the plugin. This will be a subclass of Androids Activity class. An Activity is simply a class that can run and do work. It can create a UI if it chooses, but it doesnt need to. As the checkbox suggests, this is optional, but an Activity is almost always used as the basis for an application.Min SDK Version(这个是设置程序希望运行在的系统版本)=Tips: 这里的Min SDK Version会根据我们选择的Build Target改变, 表示程序将运行在哪个系统版本之上,对应的数值关系如下: Android 1.5:Level API 3 Android 1.6:Level API 4 Android 2.01:Level API 6 Android 2.1:Level API 7 我们这里选择Android 2.1,故Min SDK Version为7=This value specifies the minimum API Level required by your application. If the API Level entered here matches the API Level provided by one of the available targets, then that Build Target will be automatically selected (in this case, entering 2 as the API Level will select the Android 1.1 target). With each new version of the Android system image and Android SDK, there have likely been additions or changes made to the APIs. When this occurs, a new API Level is assigned to the system image to regulate which applications are allowed to be run. If an application requires an API Level that is higher than the level supported by the device, then the application will not be installed.Other fields: The checkbox for Use default location allows you to change the location on disk where the projects files will be generated and stored. Build Target is the platform target that your application will be compiled against (this should be selected automatically, based on your Min SDK Version).Notice that the Build Target youve selected uses the Android 1.1 platform. This means that your application will be compiled against the Android 1.1 platform library. If you recall, the AVD created above runs on the Android 1.5 platform. These dont have to match; Android applications are forward-compatible, so an application built against the 1.1 platform library will run normally on the 1.5 platform. The reverse is not true.Your Android project is now ready. It should be visible in the Package Explorer on the left. Open the HelloAndroid.java file, located inside HelloAndroid src com.example.helloandroid).It should look like this:下面是点完Finish按钮之后自动生成的代码:packagecom.example.helloandroid;importandroid.app.Activity;importandroid.os.Bundle;publicclassHelloAndroidextendsActivity /*Called when the activity is first created.*/OverridepublicvoidonCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.main); Notice that the class is based on the Activity class. An Activity is a single application entity that is used to perform actions. An application may have many separate activities, but the user interacts with them one at a time. The onCreate() method will be called by the Android system when your Activity starts it is where you should perform all initialization and UI setup. An activity is not required to have a user interface, but usually will. Now lets modify some code!构建 UITake a look at the revised code below and then make the same changes to your HelloAndroid class. The bold items are lines that have been added.下面让我们修改一下代码:packagecom.android.helloandroid;importandroid.app.Activity;importandroid.os.Bundle;importandroid.widget.TextView;publicclassHelloAndroidextendsActivity /*Called when the activity is first created.*/OverridepublicvoidonCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); TextView tv=newTextView(this); tv.setText(Hello, Android); setContentView(tv); 执行代码:Hello,AndroidEclipse的插件使得你的程序很容易运行。选择RunOpen Run Dialog菜单。(Eclipse3.4版本中,菜单为Run-Run Configurations)可以看到这样的对话框。下一步,选择“Android Application”,点击在左上角(按钮像一张纸上有个“+”号)或者双击“Android Application”。 有个新的选项“New_configuration”。将名字改得更形象一点,如“Hello,Android”,然后按Browse按钮选择你的项目,(如果你Eclipse里有多个Android项 目需要打开,确定要选择正确)插件会会自动扫描你项目里的活动子类,然后在“活动”的下拉菜单里加载。如果你的“Hello,Android”项目只有一 个,它将被设置为默认项目,然后你可以继续。点击“Apply”按钮,这里有个例子:这样就可以了,点击“Run”按钮,Android的模拟器启动。一启动你的程序就会出现,当一切OK,你可以看到: 这样就可以了,点击“Run”按钮,Android的模拟器启动。 启动完毕后你的程序就会出现, 如果不出现,有时候是因为有键盘锁的原因, 用鼠标将键盘锁解开就一切OK,你可以看到:Hello Android.使用XML构建UI 你刚刚完成的“Hello, World”的例子使用的是我们称为“可编程”的UI层,意思是你通过编写代码来组建UI层。当你开发了足够多的UI程序,你会发现一些很糟糕的现象: 一些小的变化需要你做大量的代码改动。你常常会忘记将View连接起来,这样会导致一些错误,浪费你很多时间去调试代码。 这就是Android为什么提供一个可变化的UI开发模块:基于XML的文件。最简单解释这个概念就是演示个例子。这里有个XML的文件,它能达到和你刚才完成代码同样的效果:通常Android里XML文件结构是很简单的。只是一些标记的树形集合,每个标记就是一个视图类。在这个例子中,它就
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 铝合金门窗材料购销合同范本与铝合金门窗购销合同3篇
- 承租耕地合同(标准版)
- 湿地公园人流疏导与交通管理方案
- 装修项目团队协作管理方案
- 2025青岛海益塑业有限责任公司招聘计划备考练习试题及答案解析
- 父毌双亡房子子女共同继承合同范文8篇
- 2025四川长虹电子科技有限公司招聘主管电路设计工程师等岗位4人备考练习试题及答案解析
- 2025重庆文化旅游集团有限公司本部招聘2人备考练习题库及答案解析
- 建筑工程施工现场环境管理方案
- 北京市建材买卖合同9篇-买卖合同2篇
- 2025年海南省通信网络技术保障中心招聘考试笔试试题(含答案)
- 2025年国家卫生健康委医药卫生科技发展研究中心招聘考试笔试试题(含答案)
- 2025至2030中国PE微粉蜡市场需求量预测及前景动态研究报告
- 2025年理赔专业技术职务任职资格考试(理赔员·保险基础知识)历年参考题库含答案详解(5套)
- 2025年北京标准租房合同范本下载
- 中华人民共和国治安管理处罚法2025修订版测试题及答案
- 第一单元复习与提高(单元测试)-五年级上册数学沪教版
- TSGD7002-2023-压力管道元件型式试验规则
- 急性阑尾炎【普外科】-课件
- 文化人类学课件完整版
- 《Section B 1a-1e》获奖教案初中英语九年级全一册-九年级英语教案
评论
0/150
提交评论