简体   繁体   English

Kotlin 文件到 kotlin 类

[英]Kotlin file to kotlin class

I created a kotlin file instead kotlin class, but my file is a class truly and the icon continue as follow我创建了一个 kotlin 文件而不是 kotlin 类,但我的文件确实是一个类,图标继续如下

在此处输入图片说明

I would like if the icon was as follows (just why I feel comfortable so)我想如果图标如下(这就是为什么我觉得很舒服)

在此处输入图片说明

Thanks for any suggestions on how to solve it感谢您提供有关如何解决它的任何建议

Create a class in that file with the same name of the file:在该文件中创建一个与文件同名的类:

If the file is MyClass.kt如果文件是MyClass.kt

add to the file添加到文件中

class MyClass{

}

If the file only contains the class it will have the second icon.如果文件只包含类,它将有第二个图标。 If you add anything else to that file it will change back to the first icon.如果您向该文件添加任何其他内容,它将变回第一个图标。

The second icon (that you feel comfortable with) is for files that defines just one class with the same name as the file (a class file).第二个图标(您觉得合适)用于仅定义一个与文件同名的类(类文件)的文件。 If you add more stuff, then it's not a "class" file, but one containing a variety of stuff (just a file).如果你添加更多的东西,那么它就不是一个“类”文件,而是一个包含各种东西的文件(只是一个文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM