在Android Studio中自动导入所有内容的快捷方式是什么?

本文翻译自:What is the shortcut to Auto import all in Android Studio?

Is there any way of auto importing (like in Eclipse Shift + Ctrl + O ) in Android Studio? Android Studio中是否有任何自动导入方式(如Eclipse Shift + Ctrl + O )?

I have found only Ctrl + Alt + O which ask for each thing, and I have to press Alt + Enter to accept it. 我发现只有Ctrl + Alt + O要求每个东西,我必须按Alt + Enter接受它。

No way to do it faster? 没办法做得更快?


#1楼

参考:https://stackoom.com/question/17iKU/在Android-Studio中自动导入所有内容的快捷方式是什么


#2楼

For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes: 对于Windows / Linux,您可以转到File - > Settings - > Editor - > General - > Auto Import - > Java并进行以下更改:

  • change Insert imports on paste value to All 更改将Insert imports on paste值上的Insert imports on pasteAll

  • mark Add unambigious imports on the fly option as checked mark选中“ Add unambigious imports on the fly选项”作为选中状态

On a Mac, do the same thing in Android Studio -> Preferences 在Mac上,在Android Studio执行相同操作 - > Preferences

在Android Studio中自动导入所有内容的快捷方式是什么?

After this, all unambiguous imports will be added automatically. 在此之后,将自动添加所有明确的导入。


#3楼

By changing the keymaps settings you can use the same keyboard short cuts as in Eclipse (Or your favourite IDE) 通过更改键盘映射设置,您可以使用与Eclipse中相同的键盘快捷键(或您喜欢的IDE)

File -> Settings -> KeyMap 文件 - >设置 - > KeyMap

Android Studio -> Preferences -> KeyMap (Mac) Android Studio - >首选项 - > KeyMap (Mac)

Change keymaps settings to eclipse so that you can use the short cut keys like in eclipse. 将键盘映射设置更改为eclipse,以便您可以使用eclipse中的快捷键。 For those who just want to change this one setting, it is 对于那些只想改变这一设置的人来说,就是这样

Main Menu -> Code -> Optimize Imports... 主菜单 - >代码 - >优化进口...

在Android Studio中自动导入所有内容的快捷方式是什么?


#4楼

Android Studio --> Preferences --> Editors --> Auto Import Android Studio - >首选项 - >编辑器 - >自动导入

  • Checked Optimize imports on the fly option 选中“ 优化导入”选项
  • Checked Add unambiguous imports on the fly option 选中“ 添加明确导入”选项
  • Click Apply and OK button. 单击应用和确定按钮。

#5楼

These are the shortcuts used in Android studio 这些是Android studio中使用的快捷方式

Go to class CTRL + N 转到CTRL + N
Go to file CTRL + Shift + N 转到文件CTRL + Shift + N.
Navigate open tabs ALT + Left-Arrow ; 导航打开标签ALT +左箭头 ; ALT + Right-Arrow ALT +右箭头
Look up recent files CTRL + E 查找最近的文件CTRL + E.
Go to line CTRL + G 转到CTRL + G行
Navigate to last edit location CTRL + SHIFT + BACKSPACE 导航到上次编辑位置CTRL + SHIFT + BACKSPACE
Go to declaration CTRL + B 转到声明CTRL + B.
Go to implementation CTRL + ALT + B 转到实现CTRL + ALT + B.
Go to source F4 转到源F4
Go to super Class CTRL + U 转到超级CTRL + U.
Show Call hierarchy CTRL + ALT + H 显示调用层次结构CTRL + ALT + H.
Search in path/project CTRL + SHIFT + F 在路径/项目中搜索CTRL + SHIFT + F.

Programming Shortcuts:- 编程快捷方式: -

Reformat code CTRL + ALT + L 重新格式化代码CTRL + ALT + L.
Optimize imports CTRL + ALT + O 优化导入CTRL + ALT + O.
Code Completion CTRL + SPACE 代码完成CTRL + SPACE
Issue quick fix ALT + ENTER 发出快速修复ALT + ENTER
Surround code block CTRL + ALT + T 环绕码块CTRL + ALT + T.
Rename and Refractor Shift + F6 重命名和折射器Shift + F6
Line Comment or Uncomment CTRL + / 行注释或取消注释CTRL + /
Block Comment or Uncomment CTRL + SHIFT + / 阻止评论或取消注释CTRL + SHIFT + /
Go to previous/next method ALT + UP/DOWN 转到上一个/下一个方法ALT + UP / DOWN
Show parameters for method CTRL + P 显示方法CTRL + P的参数
Quick documentation lookup CTRL + Q 快速文档查找CTRL + Q.
Delete a line CTRL + Y 删除一行CTRL + Y.
View declaration in layout CTRL + B 在布局CTRL + B中查看声明

For more info visit Things worked in Android 有关更多信息,请访问适用于Android的内容


#6楼

For Linux (Ubuntu 14.04), you can go to 对于Linux(Ubuntu 14.04),你可以去

File -> Settings -> Editor -> Auto Import 文件 - >设置 - >编辑器 - >自动导入

check all the boxes and insert all imports on paste. 选中所有框并在粘贴时插入所有导入。

在Android Studio中自动导入所有内容的快捷方式是什么?