在项目导入现有的类文件(使用Eclipse) [英] Import an existing class file in project (Using Eclipse)

查看:699
本文介绍了在项目导入现有的类文件(使用Eclipse)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都可以使用文件 - >导入 - >现有项目纳入工作空间导入现有的Andr​​oid项目到工作区。有没有这样的方法,包括现有的Java文件(活动)
到项目。

We all can import an existing Android project into workspace using File->Import->Existing projects into workspace. Is there any such method to include an existing java file( Activity) into a project.

例如,如果我有项目P1活动hello.java。我可以复制hello.java中的src /文件夹中的项目P2,然后导入到项目中不知何故?

For example if I have activity hello.java in project P1. Can I copy hello.java in project P2 in src/ folder and then import into the project somehow?

我在这种情况下,通常做的是创建项目P2一个新的类,并从hello.java从P1手动复制code。有没有更好的办法?

What I do normally in such cases is create a new class in Project P2 and copy the code from hello.java from P1 manually. Is there any better approach?

我使用Eclipse作为编辑器。

I am using Eclipse as editor.

问候,

推荐答案

您只需右键点击你的 hello.class PROJECT1 并选择复制,不是去你的 Project2中的 的src 文件夹和右键点击 - >选择粘贴,这就是it.As我知道这是最简单的方法做that.I'm真的不知道,如果你可以从其他Projects.You导入类可以创建一个库项目,只是它包括对当前项目。这样,您将需要编写一个code一次,你将能够从所有应用程序,你需要使用它。你只需把它列入到您的项目的Eclipse的电学性能的研究。这就是它。

You can just right click on your hello.class from Project1 and select COPY , than go to your Project2's src folder and right click --> select PASTE and that's it.As I know that's the easiest way to do that.I'm not really sure if you can import classes from other Projects.You can create a library project and just include it to your current project. This way you will need to write a code once and you will be able to use it from all your application that you need. You just have to include it to your project's properities on Eclipse. That's it.

这篇关于在项目导入现有的类文件(使用Eclipse)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆