这次分享给大家一些Android开发中的快捷键:
So
Welcome to Android Studio 3.5!
通过阅读这些技巧,您可以快速熟悉IDE的主要功能。
要在编辑器中快速打开任何类,请按Ctrl+N(Navigate | Class导航类)并开始键入类的名称。从出现的下拉列表中选择类。
您可以使用Ctrl+Shift+N(导航文件)以类似的方式打开项目中的任何文件
代码完成特性允许您快速完成代码中不同类型的语句。例如,开始键入类名,然后按Ctrl+空格键完成它。当多个选项可用时,它们将显示在查找列表中。(代码补全)
You can quickly find all places where a particular class, method or variable is used in the whole project by positioning the caret at the symbol’s name or at its usage in code and pressing Alt+F7 (Edit | Find | Find Usages in the popup menu).
通过将插入符号定位在符号的名称或在代码中的用法处,并按Alt+F7(在弹出菜单中编辑“查找”“查找用法”),可以快速查找在整个项目中使用特定类、方法或变量的所有位置。
To quickly see the documentation for a class or method at caret, press Ctrl+Q (View | Quick Documentation).
要在插入符号处快速查看类或方法的文档,请按Ctrl+Q(View | Quick documentation)。
To navigate to the declaration of a class, method or variable used somewhere in the code, position the caret at the usage and press Ctrl+B (Navigate | Declaration). You can also click the mouse on usages with the Ctrl key pressed to jump to declarations.
要导航到代码中某个地方使用的类、方法或变量的声明,请将插入符号定位在该用法处,然后按Ctrl+B(导航|声明)。您还可以在按住Ctrl键的情况下单击鼠标以跳转到声明。
You can quickly navigate in the currently edited file with Ctrl+F12 (Navigate | File Structure).
It shows the list of members of the current class. Select an element you want to navigate to and press the Enter key or the F4 key.
To easily locate an item in the list, just start typing its name.
您可以使用Ctrl+F12(导航|文件结构)在当前编辑的文件中快速导航。
它显示当前类的成员列表。选择要导航到的元素,然后按回车键或F4键。
要在列表中轻松定位项目,只需键入其名称。
You can easily rename your classes, methods and variables with automatic correction of all places where they are used.
To try it, place the caret at the symbol you want to rename, and press Shift+F6 (Refactor | Rename). Type the new name in the popup window that appears, or select one of the suggested names, and press Enter.
通过自动更正类、方法和变量的所有使用位置,您可以轻松地重命名它们。
若要尝试,请将插入符号放在要重命名的符号处,然后按Shift+F6(Refactor | rename)。在出现的弹出窗口中键入新名称,或选择一个建议的名称,然后按回车键。
You may easily override methods of the base class by pressing Ctrl+O (Code | Override Methods).
To implement methods of the interfaces that the current class implements (or of the abstract base class), use Ctrl+I (Code | Implement methods).
您可以通过按Ctrl+O(Code | override methods)轻松重写基类的方法。
要实现当前类(或抽象基类)实现的接口的方法,请使用Ctrl+I(Code | implement methods)。
The SmartType code completion greatly helps to find methods and variables that are suitable in the current context, by analyzing the expected type of the whole expression. So doing, Android Studio pinpoints the top five most suitable results and highlights them on the blue background. For example, type
通过分析整个表达式的预期类型,SmartType代码的完成有助于找到适合当前上下文的方法和变量。这样一来,Android Studio就可以精确定位前五个最合适的结果,并在蓝色背景上突出显示出来。例如,键入
When using Code Completion, you can accept the currently highlighted selection in the popup list with Tab key.
Unlike accepting with the Enter key, the selected name will overwrite the rest of the name to the right of the caret. This can be especially useful for replacing one method or variable name with another.
使用“代码完成”时,可以使用Tab键接受弹出列表中当前突出显示的选择。
与使用回车键接受不同,所选名称将覆盖插入符号右侧的其余名称。这对于用另一个方法或变量名替换一个方法或变量名特别有用。
Using Alt+Insert (Code | Generate) in the editor, you can easily generate getter and setter methods for any fields of your class.
在编辑器中使用Alt+Insert(Code | Generate),可以轻松地为类的任何字段生成getter和setter方法。
To quickly select the currently edited element (class, file, method or field) in any view (Project view, Structure view or other), press Alt+F1.
要在任何视图(项目视图、结构视图或其他视图)中快速选择当前编辑的元素(类、文件、方法或字段),请按Alt+F1。
When you want to catch exceptions thrown by some code fragment, select it in the editor, press Ctrl+Alt+T (Code | Surround With) and choose try / catch. The catch blocks for all the exceptions thrown inside the block will be generated automatically.
You can customize the bodies of the generated catch blocks on the Code tab of File | Settings | File and Code Templates.
Use other items in the list to surround with other constructs.
如果要捕获某个代码片段引发的异常,请在编辑器中选择它,按Ctrl+Alt+T(代码|环绕)并选择try/catch。将自动生成在块中引发的所有异常的catch块。
可以在“文件设置”文件和代码模板的“代码”选项卡上自定义生成的捕捉块的主体。
使用列表中的其他项来环绕其他构造。
作者:冲动的MJ