简体   繁体   English

如何将Android示例导入Eclipse?

[英]How to import Android sample into Eclipse?

I am trying to import sample code from developer.android.com into Eclipse. 我试图将示例代码从developer.android.com导入Eclipse。 It doesn't include ANY build instructions. 它不包含任何构建说明。

I have tried using the "import existing android code into workspace" and "new android project from existing source" but neither option recognizes the folder which I downloaded because it only contains src and res folders. 我尝试使用“将现有的android代码导入到工作区”和“从现有的源中获取新的android项目”,但是这两个选项都不识别我下载的文件夹,因为它仅包含srcres文件夹。 I have tried overwriting a new project's src and res folders with the ones provided in the sample and updating the manifest with the new MainActivity but this produces a "R cannot be resolved to a variable error" which can't be corrected through cleaning and rebuilding. 我尝试用示例中提供的文件覆盖新项目的srcres文件夹,并使用新的MainActivity更新清单,但这会产生“ R无法解析为可变错误”,无法通过清理和重建进行纠正。 I have also tried dropping the folder into sdk/samples and copying and updating the manifest from another sample but this again produces the "R cannot be resolved" error. 我也尝试过将文件夹放入sdk/samples并从另一个示例复制和更新清单,但这又产生了“ R无法解析”错误。

File > New Project > Android > Android Sample Project > Chose the Platform > Choose the project from the list. 文件>新建项目> Android> Android示例项目>选择平台>从列表中选择项目。 It should be ready to go! 应该准备好了!

Create a new android project. 创建一个新的android项目。 Then: 然后:

File-> Import -> File System. 文件->导入->文件系统。

From Directory: your folder containing src, res (check the box) 从目录:您的包含src,res的文件夹(选中此框)

Into Folder: your created project 进入文件夹:您创建的项目

Or you can just manually copy and paste classes and things you need into your project using explorer, and then refresh the project to see them. 或者,您也可以使用资源管理器手动将需要的类和事物复制并粘贴到项目中,然后刷新项目以查看它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM