android studio和Intellij Idea自动导入并优化包设置

IDE 2020-01-01 阅读 127 评论 0

Android Studio是基于Intellij IDEA Commutity Edition开发的,Android Studio 和 Intellij Idea有很多相同之处。比如自动导入包名、自动删除一些Java代码文件没有引用到的类名,设置是一样的。

自动导入包和优化包

  • mac版本

Preferences -> Editor -> General -> Auto Import

  • windows版本

File -> Setting -> Editor -> General -> Auto Import

在Java的选项卡中,勾选:

  1. Add unambiguous imports on the fly
  2. Optimize imports on the fly (for current project)

第1项可以快速添加已明确的类名,第2项可以快速排除没有用到的类名。

手动导入包快捷键

如果项目存在相同的包名,还得手动添加。可以使用快捷键方式:

  • mac版本

⌥(Option) + Enter

  • windows版本

Alt + Enter

最后更新 2020-01-05
MIP.watch('startSearch', function (newVal, oldVal) { if(newVal) { var keyword = MIP.getData('keyword'); console.log(keyword); // 替换当前历史记录,新增 MIP.viewer.open('/s/' + keyword, {replace: true}); setTimeout(function () { MIP.setData({startSearch: false}) }, 1000); } }); MIP.watch('goHome', function (newVal, oldVal) { MIP.viewer.open('/', {replace: false}); });