KotlinIsland
KotlinIsland

Reputation: 867

Why ".kt" extension is sometimes visible and sometimes not?

In on of my Android Studio Kotlin projects, sometimes .KT is shown and sometimes not, in the Project explorer, in the Activity folder.

What is the criteria used by Android Studio to show or hide the .KT extension ?

Thanks

Upvotes: 23

Views: 3966

Answers (3)

Samuel Robert
Samuel Robert

Reputation: 11032

If a kotlin file has exactly one outer class/object/interface as the name of the file, then Android studio just shows the name without extension.

Upvotes: 23

Aidas K
Aidas K

Reputation: 171

This could happen if activity does not meet one or more of these points:

  1. One activity file should contain only one class.
  2. One activity file class name declaration must correspond to the good filename (filename must equals class name).
  3. There are no top-level declarations (constants, variables).

Upvotes: 4

KotlinIsland
KotlinIsland

Reputation: 867

Solution :

One activity file should contain only one class.

One activity file class name declaration must correspond to the good filename (filename must equals class name).

Upvotes: 0

Related Questions