AS快速开发

来源:互联网 发布:sql server与access 编辑:程序博客网 时间:2024/05/22 00:23

AS快速开发

本文参考yissan的一篇博客,重新写了一篇适合自己的笔记
点击进入博客

概述:

​ 现如今开发越来越追求效率和节奏,节省出时间做更多的事情,除了开发技术上的封装等,开发工具的使用技巧也是很重要的。今天主要介绍Android Studio的快速开发。

Postfix completion

1. 介绍:后缀实现

2. 常用后缀介绍

  1. .cast 强制转换
  2. .if
  3. .else 对if语句的取反
  4. .field 生成成员变量——–(与ctrl + alt + F 类似)
  5. .fori 简单for循环
  6. .for 使用增强for循环
  7. .forr 反向for循环
  8. .null 快速判空
  9. .nn/.notnull 快速判断非空
  10. .switch
  11. .inst/.instanceof
  12. .var 生成一个局部变量——-(不多说,直接alt + enter)
  13. .par 为表达式添加括号

:下面两个需要添加plugin:android Postfix completion

  • .log 快速打印log

  • .toast 快速弹toast

3. 更多查看

​ Settings–>Editor–>General–>Postfix Completion

Live Templates

1. 介绍

​ 活动模板。让您插入频繁使用的或自定义的代码结构,快速、高效、准确地构建到您的源代码文件中。

2. 系统模板

​ Settings–>Editor–>Live Templates

3. 自定义模板

使用较少

4. 使用技巧

  1. 快速添加代码到live templates中,选中代码–>Tools–>Save as Live Templates
  2. 当不记得模板的缩写时,Windows:ctrl + j ——-Mac:cmd + j有惊喜!!

快捷键

1. 常用快捷键介绍

  • Windows / Mac
    1. ctrl + shift + A / cmd + shift + A 查找AS所有动作功能 (超级强大)
    2. 双击shift / 双击shift 查找工程中的所有文件 (超级强大)
    3. F3 / cmd + G 查找下一个,配合ctrl + F 使用——ps:按回车键也行
    4. shift + F3 / cmd + shift + G 查找上一个,配合ctrl + F 使用
    5. ctrl + alt + B / cmd + alt + B 找到接口/类的实现类实现方法 ,在mvp模式常用
    6. F2 / F2 快速定位错误
    7. ctrl + shift + backspace / cmd + shift + backspace 回到上次编辑的位置
    8. ctrl + shift + V / cmd + shift + v 从粘贴簿选择粘贴
    9. ctrl + H / cmd + H 查看class的继承结构
    10. ctrl + alt + H / cmd + alt + H 查看方法的层次调用关系
    11. ctrl + P / cmd + P 查看方法的参数类型
    12. ctrl + Q / cmd + Q 快速查看简要文档

2. 系统默认快捷键

1) 普通类型

description 解释 Windows/Linux Mac Open settings dialogue 快速打开设置 Ctrl + Alt + S Cmd + , (comma) Open project structure dialog 打开项目结构 Ctrl + Alt + Shift + S Cmd + ; (semicolon)

2) 追踪和搜索

description 解释 Windows/Linux Mac Find 查找 Ctrl + Alt + S Cmd + , (comma) Search everything (including code and menus) 查找所有 点击shift两次即可搜索 点击shift两次即可搜索 Find next 顺序向下查找 F3 Cmd + G Find action 查找功能,超级强大,as的所有功能可以通过该功能来查找 Ctrl + Shift + A Cmd + Shift + A Find class 快速找到类并打开文件 Ctrl + N Cmd + O Find file (instead of class) 快速查找文件 Ctrl + Shift + N Cmd + Shift + O Find in path 在项目下的所有路径查找 Ctrl + Shift + F Cmd + Shift + F Recently opened files pop-up 列出最近打开的文件 Ctrl + E Cmd + E Recently edited files pop-up 列出最近编辑过的文件 Ctrl + Shift + E Cmd + Shift + E Go to last edit location 回到最近一次编辑的位置 Ctrl + Shift + Backspace Cmd + Shift + Backspace Close active editor tab 关闭当前编辑的文件 Ctrl + F4 Cmd + W Open type hierarchy 打开类型层次关系 Ctrl + H Cmd + H Open method hierarchy 打开方法层次关系 Ctrl + Shift + H Cmd + Shift + H Open call hierarchy 打开调用层次关系 Ctrl + Alt + H Cmd + Option + H

3) 写代码常用快捷键

description 解释 Windows/Linux Mac Generate code (getters, setters, constructors, hashCode/equals, toString, new file, new class) 快速生成各种方法 Alt + Insert Cmd + N Override methods 显示所有可以重写的方法 Ctrl + O Cmd + O Implement methods 显示所有可以实现的方法 Ctrl + I Cmd + I Surround with (if…else / try…catch / etc.) 快速为语句生成if else,try catch for循环等 Ctrl + Alt + T Cmd + Option + T Delete line at caret 删除光标所在行 Ctrl + Y Cmd + Backspace Duplicate current line or selection 快速产生新的当前行,或者新的多行代码 Ctrl + D Cmd + D Quick documentation lookup 快速查看简要文档 Ctrl + P Cmd + P Go to declaration (directly) 找到变量或方法声明处 Ctrl + B or Ctrl + Click Cmd + B or Cmd + Click Go to implementations 找到一个接口的实现类,接口方法的是实现处 Ctrl + Alt + B Cmd + Alt + B Go to super-method/super-class 找到父类或父类方法 Ctrl + U Cmd + U Toggle project tool window visibility 显示或隐藏as左边的项目窗口 Alt + 1 Cmd + 1 Comment/uncomment with line comment 快速单行注释或去除注释 Ctrl + / Cmd + / Comment/uncomment with block comment 多行注视或除去多行注释 Cmd + Shift + / Cmd + Shift + / Project quick fix (show intention actions and quick fixes) 给出当前问题的多种解决方法(该方法非常常用) Alt + Enter Option + Enter Reformat code 格式化代码 Ctrl + Alt + L Cmd + Option + L Next/previous highlighted error 找到下一个/上一个错误 F2 / Shift + F2 F2 / Shift + F2

4) 编译运行

description 解释 Windows/Linux Mac Build 编译 Ctrl + F9 Cmd + F9 Build and run 编译并运行 Shift + F10 Cmd + R

5) 调试

description 解释 Windows/Linux Mac Debug debug模式运行 Shift + F9 Shift + F9 Step over 下一步 F8 F8 Step into F7 F7 Smart step into Shift + F7 Shift + F7 Resume program 恢复程序 F9 Cmd + Option + R

6) 修改

description 解释 Windows/Linux Mac Safe delete 安全删除 Alt + Delete Cmd + Delete Extract method 提取方法 Ctrl + Alt + M Cmd + Option + M Extract variable 提取变量 Ctrl + Alt + V Cmd + Option + V Extract field 提取全局变量 Ctrl + Alt + F Cmd + Option + F Extract constant 提取常量 Ctrl + Alt + C Cmd + Option + C Extract parameter 提取参数 Ctrl + Alt + P Cmd + Option + P

7) 版本控制/本地历史

description 解释 Windows/Linux Mac Commit project to VCS 提交 Ctrl + K Cmd + K Update project from VCS 从VCS中更新项目 Ctrl + T Cmd + T View recent changes 查看最近修改 Alt + Shift + C Option + Shift + C Open VCS popup 打开版本控制设置窗口 Alt + ` (backquote) Cmd + V

扩展

自定义快捷键

主要在用系统默认的。。。

插件

这里就不介绍了。常用的就butterknife、gsonformat等。可以看看我参考的这篇博客。

就说这么多了,欢迎小伙伴指出不足之处。

原创粉丝点击