如何从Android中的另一个项目,包中导入的.java [英] How to import .java from another project AND package in android

查看:290
本文介绍了如何从Android中的另一个项目,包中导入的.java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在努力在大学的一个项目(项目A)具有从一个类是另一个项目(项目B),年前延长。
这是工作的Eclipse之下,开发Android应用程序,所以这是我们谈论的其实活动。

We're working on a project (Project A) in college that has to extend from a class that is another project (Project B), made years ago. This is working under Eclipse, and developing apps for android, so this is in fact Activities we're talking about.

到目前为止,我已经试过这样:

So far I've tried this:


  • 项目A的构建路径中添加项目B(在Projects标签)

  • 导入,具有完整的包名和.java名称。

问题是,每次我找到的解决方案是使用的.jar工作,与.class或甚的apk文件,但我不与工作,项目B是一个简单的项目全.java文件的

The thing is that every solution I've found is for working with .jar, .class or even .apk files, but I'M NOT working with that, project B is a simple project full of .java files.

要成为它更加清楚一点,项目A有一个名为ClassFromProjectA类,B项目有一个像 ClassFromProjectB A类。 ClassFromProjectA 就像如下:

To be a little more clear about it, Project A has a class named ClassFromProjectA, and Project B has a class like ClassFromProjectB. ClassFromProjectA is like follows:

public class ClassFromProjectA extends ClassFromProjectB{}

ClassFromProjectB就像如下:

ClassFromProjectB is like follows:

public class ClassFromProjectB extends ListActivity implements OnInitListener, OnGesturePerformedListener {}

唯一的东西ClassFromProjectB是在做什么,uppon从中延伸,它改变了一个ListView的默认布局,适用于特定的导航选项,适用手势从中延伸的每一次活动,和一对夫妇更多的调整。

The "only" thing ClassFromProjectB is doing is, uppon extending from it, it changes the default layout for a ListView, applies specific navigation options, applies gestures to every activity extending from it, and a couple more tweaks.

如果我有这样的:

public class ClassFromProjectA extends ListActivity{}

一切正常,我的同班同学,没有错误,没有警告,什么都没有。

Everything works fine with my class, no errors, no warnings, no nothing.

我们绝对相信 ClassFromProjectB 工作,这是一个previous succesfull学院项目,它也有它的文件中的一个实例活动检查功能,一切就像一个魅力。这就是东西,虽然,它仅适用,因为它是在相同的项目文件。但是,我们不能做到这一点,我们有进口和扩展,并且它不干活的。

We are ABSOLUTELY sure that ClassFromProjectB is working, it was a previous succesfull college project, and it also has an Example activity within its files to check functionality, and everything works like a charm. That's the thing though, it only works because it is in the same project file. But we CAN'T do that, we have to import and extend, and it isn't workin'.

请让我知道,如果你知道如何使这项工作,或点我在正确的方向。

Please, let me know if you know how to make this work, or point me in the right direction.

推荐答案

如果您有需要你的项目(项目A)里面包括完整的B项目,你可以做什么。

What you can do if you have the complete project B that you need to include inside your project (project A).


  1. 请项目B通过以下方式库:

    • 右键点击为项目B 在Eclipse,并单击属性

    • 选择的Andr​​oid ,然后在 isLibrary 复选框。

  1. Make Project B a library in the following manner :
    • Right click the project B in Eclipse, and click on Properties.
    • Select Android then the isLibrary check box.

  • 右键点击项目A 在Eclipse,并单击属性

  • 选择的Andr​​oid ,然后点击添加... 即可。

  • 您应该看到在Eclipse中的所有库项目的机器上的一个列表。你也应该看到项目B 。选择它并点击确定

  • 您应该看到项目B在库列表。

  • Right click the project A in Eclipse, and click on Properties.
  • Select Android then click on Add....
  • You should see a list with all the library projects inside eclipse on your machine. You should also see Project B. Select it and click OK.
  • You should see Project B in the list of libraries.

现在,你应该能够从项目B包导入到项目A和使用其类,没有问题。

Now you should be able to import packages from Project B to project A and use its classes with no problem.

这篇关于如何从Android中的另一个项目,包中导入的.java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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