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
android studio auto complete: how to display constructors with parameters
提问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 类的所有构造函数。
While auto complete in android studio for Intent class is displayed without parameters as following.
android studio 中的自动完成 Intent 类不带参数显示如下。
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 Action
menu item and type Registry
to go to the Registry. Here enable the java.completion.show.constructors
option.
还可以通过启用隐藏选项来显示重载的构造函数。调用Help | Find Action
菜单项并键入Registry
以转到注册表。在这里启用该java.completion.show.constructors
选项。
Copied From: https://stackoverflow.com/a/43639241/2920861
回答by Anil Meenugu
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.
我通常首先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
在 eclipse ctrl+space 中为您提供类的所有构造函数
in android studio no need short cut key :)
在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 相同的行为