AVEbrahimi
AVEbrahimi

Reputation: 19164

Kotlin auto complete overrides in Android Studio

I have this variable defined in a Kotlin file, but Android Studio doesn't suggest implementing methods, am I missing something :

private val mGestureListener = object : GestureDetector.SimpleOnGestureListener() {

}

Upvotes: 6

Views: 4061

Answers (2)

Henry
Henry

Reputation: 17851

SimpleOnGestureListener is a non-abstract class. Hence the IDE doesn't show the Implement methods options by default. The IDE shows this option only when there is at least one method that's not implemented in the class.

If you want to show the Override methods option, then place the cursor inside the braces and choose Code -> Override Methods... (Ctrl+O), or if you already know the methods that you want to override, just start typing the method name and it will show up in auto complete.

Upvotes: 8

ice1000
ice1000

Reputation: 6569

You can use Ctrl+O inside the object : Xxx block to open a dialog to see methods to override, and Ctrl+I to see methods to implement.

This is nearly the same as Henry's answer, but he uses mouse, I use keyboard.

Click or press enter on some methods to generate empty implementations, and type letters to do text-based search.

If you didn't find what you expected, you're probably overriding the wrong class/interface.

If you have abstract methods not overriden, you'll see red wave line under object. Alt+Enter will help you solve problem in such situation.

Upvotes: 8

Related Questions