在同一个项目中使用Java和Kotlin活动

huangapple go评论97阅读模式
英文:

Using Java and Kotlin activities in the same project

问题

一如既往,新手们又来问那些你们讨厌的愚蠢问题。因此,请原谅我接下来要提出的问题:

Android Studio是否允许在同一个项目中同时使用Java和Kotlin的活动?我的意思是在同一个项目中。嗯,我不想将代码从Java转换为Kotlin,我希望它保持在Java中,但另一方面,当然有一些活动会使用Kotlin编写。

我提出这个问题的原因是因为我尝试过这样做,但我的应用在从Kotlin活动切换到Java活动时崩溃了。所以,在我继续之前,我想为什么不请教一下,也许你们这些行家能够解答一些问题,也可能是某些代码错误。请温柔一点,我还是个新手。

提前谢谢你们。

英文:

As always, the newbies are here to ask those dumb question you guys hate so much. As such, please excuse the following question:

Does Android studio allow you to use Java and Kotlin activities interchangeably? That is in the same project. Well, I don't want to convert the code fekm Java to Kotlin, I want it to remain in Java, while on the other hand, some activities will be in Kotlin of course.

Reason, I ask this is because I tried to do this but I had my app crashing as it switched from a Kotlin to a Java activity. So, before I proceed with it, I thought why not, maybe you gurus can shed some light and there might be some code error instead. Be gentle, I'm still a newbie.

Thank you in advance.

答案1

得分: 2

事实上,您可以。我是一名安卓应用开发者,同时在使用这两种语言。此外,当JetBrains推出Kotlin时,他们表示并展示了这两种语言的类可以在单个项目中互相交互。

您可以访问这个链接,您会更好地了解如何做到这一点。

英文:

As matter of fact you can. I'm a android app developer and I'm using both the languages at same time. Also, when JetBrains launched kotlin that time they said and showed both language classes can interact together in single project.

You can goto this link you will get a better idea how to do this.

huangapple
  • 本文由 发表于 2020年4月6日 18:51:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/61058099.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定