快速导包

快速导包

在 Android Studio 中,我们可以通过 Alt + Enter 和 Control + Alt + O 进行导包和清除无用导包,但我们都生活在2016年了,这些事情应当快速自动完成。 





未开启imports on the fly





开启imports on the fly

配置方法

  • File | Settings 打开设置
  • 选择 Editor | General | Auto Import
  • 勾选 Optimize imports on the fly
  • 勾选 Add unambiguous imports on the fly




设置

PS:这里我补充一下,关于这个配置,个别朋友在问,如果我的项目中两个甚至多个包下都有一个类叫 ImageLoader ,自动导入的结果有没有可能不是我想要的包下的?兄弟你放心,你去查一下 unambiguous 的意思就知道了。针对包名不确定的情况, Android Studio 会选择 No can no import, you can you up ,不会自作聪明,而是会让你自己手动导入。所以,请放心使用。

ps:在删除相关代码时相应的包也会自动删除

猜你喜欢

转载自blog.csdn.net/hizhangyuping/article/details/81062171