Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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() {

}
like image 690
AVEbrahimi Avatar asked Dec 13 '17 08:12

AVEbrahimi


2 Answers

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.

like image 141
Henry Avatar answered Nov 05 '22 12:11

Henry


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.

like image 35
ice1000 Avatar answered Nov 05 '22 12:11

ice1000