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.classfromProject1and selectCOPY, than go to yourProject2'ssrcfolder andright click–> selectPASTEand 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 alibrary projectand 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.