快速导包

在 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:在删除相关代码时相应的包也会自动删除

相关文章:

  • 2021-12-26
  • 2022-01-11
  • 2022-12-23
  • 2021-05-01
  • 2022-12-23
  • 2021-11-19
  • 2021-04-19
猜你喜欢
  • 2021-11-12
  • 2021-09-20
  • 2022-02-08
  • 2022-12-23
  • 2021-11-23
  • 2021-11-23
  • 2021-12-25
相关资源
相似解决方案