How to auto import the necessary classes in Android Studio with shortcut?

爷,独闯天下 提交于 2019-11-27 00:24:51

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*

Go on the missing declaration with cursor and press alt+enter

tning

Ctrl + Alt + O to optimize imports

On my Mac Auto import option was not showing it was initially hidden

Android studio ->Preferences->editor->General->Auto Import

and then typed in searched field auto then auto import option appeared. And now auto import option is now always shown as default in Editor->General. hopefully this option will also help others. See attached screenshot

jkhosla

To import classes on the fly :

On OSX press Alt(Option) + Enter.

File -> Settings -> Keymap Change keymaps settings to your previous IDE to which you are familiar with

You can also use Eclipse's keyboard shortcuts: just go on preferences > keymap and choose Eclipse from the drop-down menu. And all your Eclipse shortcuts will be used in here.

On Windows with Android Studio 1.5.1 : File --> Settings --> Editor --> General --> Auto Import

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!