It's possible to import a single declaration shortcut key everyone is easy to find, Alt+enter. But if I want all the declarations in the import file at once, what is this shortcut key, looking for, is not found, previously in Eclipse is ctrl+1, but after finishing Keymap does not work. In fact, I did not find, I guess there is no shortcut key, of course, if there is this shortcut key, found, I will update the next. Why I guess I don't have this shortcut, because Android Studio has an auto import feature in its settings.
About auto Import settings There are several, estimated that many people look also Meng, my side explained, if I explain you still do not understand, then you do not have to control what it is to do, directly hook on the good. Such as:
Explain it individually:
Xml
- Show Import Popup, which is used for editing XML, automatically pops up an import dialog box asking if you need to import.
Java
- Insert Imports on paste:(all ask None), which is actually an option for you to ask for an imported package when you copy the code.
All : When you choose this item, you paste the code, you need to import the package name, will automatically import, do not play the prompt boxask: When you choose this item, you paste the code, there is a need to import the package name, will pop the prompt box, ask you want to import None: When you choose this, the code you paste, the package name that you need to import, does not play the prompt box, and does not automatically import.
- Show Import Popup: This is different from the above insert imports on paste. Ha, don't mix, this means that when the declaration of the class you entered is not imported, a selection dialog box pops up. But this is a bit of a problem to note here. Whether you check or not, anyway, the dialog box will not pop out, after you lose the class name, the declaration is automatically imported. So I guess this could be a bug in Android studio.
- Optimize imports on fly: This is actually the same as the shortcut key Ctrl+shift+o/ctrl+alt+o, which is to remove the unused declarations.
- Add Unambiguous importson the fly: This is the automatic import function, when you enter the class name, the declaration is automatically imported.
- Exclude from Import and completion: This is actually your custom Import. You don't have to pay attention, generally you can't use it.