Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio auto complete: how to display constructors with parameters

The auto Complete in eclipse displays all constructors with parameters, but Android studio doesn't.

For example see the following screenshot in eclipse, it displays all constructors of Intent class.

enter image description here

While auto complete in android studio for Intent class is displayed without parameters as following.

enter image description here

How to change auto complete in android studio to display all constructors with parameters ?

like image 386
Eng. Samer T Avatar asked Jul 09 '15 10:07

Eng. Samer T


People also ask

Can constructors specify parameters?

Constructors can specify parameters but not return types. If a class does not define constructors, the compiler provides a default constructor (p. 83) with no parameters, and the class's instance variables are initialized to their default values.

How do you pass parameters to a constructor?

When you declare a parameter to a method or a constructor, you provide a name for that parameter. This name is used within the method body to refer to the passed-in argument. The name of a parameter must be unique in its scope.

Can constructors take input parameters?

A Java class constructor initializes instances (objects) of that class. Typically, the constructor initializes the fields of the object that need initialization. Java constructors can also take parameters, so fields can be initialized in the object at creation time.

Which constructor contains object as parameter?

Copy constructors A Copy constructor has one formal parameter that is the type of the class (the parameter may be a reference to an object).


2 Answers

I usually start with Ctrl+P to see what arguments are accepted (auto guess complete is way to error prone in my opinion). And if as in your case you want to fill in name type n a dropdown menu appears with all available variables/fields (etc) starting with n Arrow Up/Down and Tab to select name, or Ctrl+Space to select a method (or even Ctrl+Alt+Space to be killed by suggestions;-), followed by , and v Tab for value.

File --> Keymap --> Main Menu --> Parameter Info --> Right Click --> Add keyboard short cut

I dont know whether it is added advantage or not while creating a constructor (ctrl+shift+space) will give default constructor after that cursor stays within the parenthesis gives all parametrized constructor of a particular class without any short cut :)

in eclipse ctrl+space with give you all the constructors of class enter image description here

in android studio no need short cut key enter image description here:)

You Can Use Eclipse Short Cut Keys in Android Studio Follow Below Process : File -- > Settings -- > Keymap ---> under Keymaps Drop down Select Eclipse option

Cheers

like image 152
Anil Meenugu Avatar answered Sep 27 '22 19:09

Anil Meenugu


Real answer to the Question:

It is also possible to show overloaded constructors by enabling a hidden option. Invoke the Help | Find Action menu item and type Registry to go to the Registry. Here enable the java.completion.show.constructors option. constructor overloads in completion

Copied From: https://stackoverflow.com/a/43639241/2920861

like image 42
Crigges Avatar answered Sep 27 '22 19:09

Crigges