Beko
Beko

Reputation: 1002

AndroidStudio how to import inner class directly

Say I have a package p that contains the following class:

class A {
  // ...

  public static class B { /* ... */ }
}

Now, when I use class B in another package Android will give me the option to automatically import it via Alt+Enter. However, it will only import class Aand the usage of B in the code will look like this: A.B.

I don't like this. I also don't want to manually alter the import statement [import p.A to import p.A.B] everytime I import class B.

How can I change this so that AndroidStudio will always import p.A.B whenever I use B?

Edit: It doesn't look like it's doable in Settings->Editor->General->Auto Import

Upvotes: 3

Views: 747

Answers (1)

Nikunj Peerbits
Nikunj Peerbits

Reputation: 795

You can do it this way

go to Settings > Code Style > Java > Imports and mark the Insert imports for inner classes checkbox.

Upvotes: 2

Related Questions