开发者

Import an existing class file in project (Using Eclipse)

开发者 https://www.devze.com 2023-04-09 03:03 出处:网络
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)

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.

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?

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?

I am using Eclipse as editor.

Regards,


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消