Java android studio 自动完成:如何显示带有参数的构造函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31315347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 10:54:20  来源:igfitidea点击:

android studio auto complete: how to display constructors with parameters

javaandroideclipseandroid-studio

提问by Eng. Samer T

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

eclipse 中的 auto Complete 会显示所有带参数的构造函数,但 Android studio 没有。

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

例如在 Eclipse 中看到以下屏幕截图,它显示了 Intent 类的所有构造函数。

enter image description here

在此处输入图片说明

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

android studio 中的自动完成 Intent 类不带参数显示如下。

enter image description here

在此处输入图片说明

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

如何在android studio中更改自动完成以显示所有带参数的构造函数?

采纳答案by Crigges

Real answer to the Question:

问题的真实答案:

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

还可以通过启用隐藏选项来显示重载的构造函数。调用Help | Find Action菜单项并键入Registry以转到注册表。在这里启用该java.completion.show.constructors选项。 构造函数重载完成

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

复制自:https: //stackoverflow.com/a/43639241/2920861

回答by Anil Meenugu

I usually start with Ctrl+Pto 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 dropdownmenu appears with all available variables/fields(etc) starting with n Arrow Up/Downand Tab to select name, or Ctrl+Spaceto select a method (or even Ctrl+Alt+Spaceto be killed by suggestions;-), followed by , and v Tab for value.

我通常首先Ctrl+P查看接受哪些参数(在我看来,自动猜测完成是一种容易出错的方式)。如果在你的情况下你想填写名称类型 nadropdown菜单出现所有可用variables/fields(等)以 nArrow Up/Down和 Tab开头的选择名称,或Ctrl+Space选择一个方法(甚至Ctrl+Alt+Space被建议杀死;-),然后是, 和 v Tab 值。

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 :)

我不知道在创建构造函数时是否增加了优势(ctrl+shift+space)将在光标停留在括号内后给出默认构造函数给出特定类的所有参数化构造函数而没有任何捷径:)

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

在 eclipse ctrl+space 中为您提供类的所有构造函数 在此处输入图片说明

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

在android studio中不需要快捷键在此处输入图片说明:)

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

您可以在 Android Studio 中使用 Eclipse Short Cut Keys 按照以下过程:文件 --> 设置 --> 键盘映射 ---> 在键盘映射下下拉选择 Eclipse 选项

Cheers

干杯

回答by Malwinder Singh

After writing default constructor, press Ctrl+P. You will see list of possible parameters that can be fill in constructor.

编写默认构造函数后,按Ctrl+P。您将看到可以在构造函数中填充的可能参数列表。

回答by LynAs

Go to Settings -> Editor -> General -> Code Completion -> Auto Popup in(ms) set it 10

转到 Settings -> Editor -> General -> Code Completion -> Auto Popup in(ms) 将其设置为 10

Then you will see same behavior as eclipse

然后你会看到与 eclipse 相同的行为