我可以将一个文件中的代码包含到下一个文件中吗,类似于 html 中的 Includes

发布于 2024-12-09 21:22:28 字数 370 浏览 1 评论 0原文

好吧,请温柔善良。我在大学上一门 Android 编程课程,第一学期是我们的老师,所以他和我们一样学习……没有什么反对他的,他是一位好老师,只是不知道答案。

我不知道如何将其放入 Android/java 语言中,所以这里...

有没有一种方法可以在 Android 的网页设计中使用类似于 Includes 的东西。我希望将类似的java代码从一个活动添加到下一个活动,我可以创建一个文件,如果我更改此文件,它将在其包含的所有文件中发生更改。

我知道它可以通过 XML 文件来完成,但我找不到任何东西来表明它可以在实际编码中完成......但话又说回来,我不知道正确的术语。请任何帮助都会很棒。感谢您花时间阅读并回答我。如果这是在其他地方,我很抱歉,我只是找不到它..再次感谢

Ok, Please be gentle and kind. I am taking an Android Programming class in college and its our teachers first semester so he is learning as we are... Nothing against him, he's a good teacher, just doesn't know the answer.

I don't know how to put this in Android/java language so here goes...

Is there a way to use something similar to Includes, in web design, in Android. I am looking to add similar java code from one activity to the next, can i make a file that if i change this one file it will change in all the files its included it.

I know it can be done with the XML files but i couldn't find anything to show that it can be done in the actually coding... but then again i don't know the correct terminology. Please any help would be great. And thank you for taking the time to read and answer me. I apologize if this was somewhere else, I just couldn't find it.. Thanks again

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮是我掰弯的 2024-12-16 21:22:28

将您希望“包含”的任何内容放入 Java 类中,然后导入它们。 http://leepoint.net/notes-java/language/10basics/import.html

Put anything you wish to "include" in Java classes, then import them. http://leepoint.net/notes-java/language/10basics/import.html

我很坚强 2024-12-16 21:22:28

Android编程课!我会喜欢在大学里这样做...

无论如何,如果您使用 Eclipse 作为 IDE,它应该会自动从您的 java 导入中获取任何更改。如果您选择重构项目中的其他 java 类,例如重命名(使用“更新所有引用”),将更新项目中对该类的所有引用。

如果适合您的需求,您还可以使用 Maven(依赖管理)在构建时提取最新的第三方(或其他).jar。

:)

Android Programming class! I would've loved that in University...

Regardless, if you're using Eclipse for your IDE, it should pickup any changes from your java imports automatically. If you choose to refactor other java classes within your project, a rename for example (with "Update All References"), will update all references to that class across your project.

You could also use Maven (dependency management) to pull the latest third-party (or other) .jars at build time, if that's applicable to what your needs are.

:)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文