2013-05-17 17:45
采纳率: 25%
浏览 651

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

Is there any way of auto importing (like in Eclipse Shift+Ctrl+O) in Android Studio?

I have found only Ctrl+Alt+O which ask for each thing, and I have to press Alt+Enter to accept it.

No way to do it faster?


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

11条回答 默认 最新

  • csdnceshi56
    lrony* 2013-05-17 18:56

    For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes:

    • change Insert imports on paste value to All

    • markAdd unambigious imports on the fly option as checked

    On a Mac, do the same thing in Android Studio -> Preferences

    enter image description here

    After this, all unambiguous imports will be added automatically.

    点赞 评论
  • csdnceshi55
    ~Onlooker 2014-08-21 06:12

    By changing the keymaps settings you can use the same keyboard short cuts as in Eclipse (Or your favourite IDE)

    File -> Settings -> KeyMap

    Android Studio -> Preferences -> KeyMap (Mac)

    Change keymaps settings to eclipse so that you can use the short cut keys like in eclipse. For those who just want to change this one setting, it is

    Main Menu -> Code -> Optimize Imports...

    enter image description here

    点赞 评论
  • csdnceshi72
    谁还没个明天 2014-12-23 23:02

    Android Studio --> Preferences --> Editors --> Auto Import

    • Checked Optimize imports on the fly option
    • Checked Add unambiguous imports on the fly option
    • Click Apply and OK button.
    点赞 评论
  • csdnceshi71
    Memor.の 2015-01-13 07:11

    These are the shortcuts used in Android studio

    Go to class CTRL + N
    Go to file CTRL + Shift + N
    Navigate open tabs ALT + Left-Arrow; ALT + Right-Arrow
    Look up recent files CTRL + E
    Go to line CTRL + G
    Navigate to last edit location CTRL + SHIFT + BACKSPACE
    Go to declaration CTRL + B
    Go to implementation CTRL + ALT + B
    Go to source F4
    Go to super Class CTRL + U
    Show Call hierarchy CTRL + ALT + H
    Search in path/project CTRL + SHIFT + F

    Programming Shortcuts:-

    Reformat code CTRL + ALT + L
    Optimize imports CTRL + ALT + O
    Code Completion CTRL + SPACE
    Issue quick fix ALT + ENTER
    Surround code block CTRL + ALT + T
    Rename and Refractor Shift + F6
    Line Comment or Uncomment CTRL + /
    Block Comment or Uncomment CTRL + SHIFT + /
    Go to previous/next method ALT + UP/DOWN
    Show parameters for method CTRL + P
    Quick documentation lookup CTRL + Q
    Delete a line CTRL + Y
    View declaration in layout CTRL + B

    For more info visit Things worked in Android

    点赞 评论
  • csdnceshi56
    lrony* 2015-01-21 23:55

    For Linux (Ubuntu 14.04), you can go to

    File -> Settings -> Editor -> Auto Import

    check all the boxes and insert all imports on paste.

    enter image description here

    点赞 评论
  • csdnceshi58
    Didn"t forge 2015-02-13 06:53

    Go to File -> Settings -> Editor -> Auto Import -> Java and make the below things:

    Select Insert imports on paste value to All

    Do tick mark on Add unambigious imports on the fly option and "Optimize imports on the fly*

    点赞 评论
  • csdnceshi80
    胖鸭 2015-10-23 08:42

    Note that in my Android Studio 1.4, Auto Import now under General

    (Android Studio --> Preferences --> Editors --> General --> Auto Import)

    enter image description here

    点赞 评论
  • csdnceshi60
    ℡Wang Yan 2016-02-18 16:42

    In the Latest Version of Android Studio, the options for Auto-Import is enabled by default, so kudos no need to worry about that.

    On Windows: If for some reasons auto-import is not enable you can go to settings by typing shortcut: Ctrl+Alt+S.

    In the Search term just type 'Auto-Import' and then select 'Add unambiguous Imports on the fly' and click Ok.

    That's it. You are Done. SnapShot of Auto_import

    点赞 评论
  • csdnceshi62
    csdnceshi62 2016-03-02 18:55

    On Windows, highlight the code that has classes which need to be resolved and hit Alt+Enter

    点赞 评论
  • csdnceshi64
    游.程 2016-05-21 12:06

    You can make short cut key for missing import in android studio which you like

    1. Click on file Menu
    2. Click on Settting
    3. click on key map
    4. Search for "auto-import"
    5. double click on auto import and select add keyboard short cut key
    6. that's all

    enter image description here

    enter image description here

    enter image description here

    Note: You can import single missing import using alt+enter which shown in pop up

    enter image description here

    点赞 评论
  • csdnceshi62
    csdnceshi62 2018-03-20 08:47

    File > Settings > Editor > General >Auto Import (Mac: Android Studio > Preferences > Editor > General >Auto Import).

    Select all check boxes and set Insert imports on paste to All. Unambiguous imports are now added automatically to your files.


    点赞 评论