英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论