Android Studio shortcuts and handy plugins

Source: Internet
Author: User
Tags try catch

reprint: http://www.jianshu.com/p/c439605a4364Overview

Nowadays, the development of more and more efficiency and rhythm, save time to do more things, in addition to the development of technical packaging, development tools, the use of skills is also very important, today, according to their own experience to introduce the rapid development of Android studio.

Postfix completion

Postfix completion is an early feature of IntelliJ idea, which implements another expression you want based on the expressions you've entered and the suffixes you've added. For example, after a Boolean expression, a suffix if is an if statement.
Common Suffixes Introduction
Here are some of the more commonly used suffixes in personal work.

  • Cast
    When a variable requires a type conversion, do you often fall back to the variable name several times, and then enter the type in parentheses, now you just need to. Cast after the dashing input type.
  • If
    You have a better choice for the IF statement. If

  • Else
    else is if the reverse is so fast

  • Field
    Let's say your code is very long, and suddenly you have to assign a value to a variable in line 1000 and declare it as a global variable, is it really troublesome to go back and declare it? With field, it can be anywhere.

  • Fori
    Simple and fast for loop, that's it.

  • For
    For loop the second type, enhanced for loop (using. ITER is the same effect)

  • Forr
    For loop the third type, reverse for loop. Forr

  • Null
    Fast Empty

  • Nn/notnull
    Fast judgment of non-empty. nn, consistent with. Notnull effect

  • Switch
    . switch generates a switch statement directly from an object of a type such as a string enumeration

  • Inst/instantsof
    Fast instanof judgment and type conversion

  • Var
    Quickly generate variables for an expression

  • Par
    Quickly add parentheses to an expression

  • Log
    Fast log, want to output the content. Log

  • Toast
    Quick toast, want to output the content. Toast can be


    In addition to the above suffix statement, Android Studio has many other suffix statements, because the personal feel is not very common, so no mention, you can open Setting-editor-general-postfix completion see more usage.
    Put a picture of postfix completion below

Live Templates

Allows you to insert frequently used or custom code structures to build into your source code files quickly, efficiently, and accurately.
We can directly open the Settings/preferences dialog box and select Live templates under Editor to view


Live Templates


As you can see, Android Studio has provided us with a large number of templates.
Simple knowledge of the system template
Here we get a simple look at live templates through a template provided by the system.
Look at a picture first


Add your own code template


Android is a group name, and the system provides many templates under the group.
We can add our own group or template by clicking + in the upper right corner.
Abbreviation is the abbreviation of the template, the definition of the abbreviation can be directly entered into the abbreviation for the template specific content.
Description will be prompted with an accompanying description at the time of input.
Tempplate text is the specific content, the specific content can be variable
To make a variable definition, the template in the definition of the name and value two variables.
You can edit the variables by clicking the Edit Variables button on the right, then the following dialog will pop up.



You can see that name specifies the default value Name,value is a random number within 1000. There are many details about the variables, because of the length of the reasons, no longer discussed in detail here, follow-up I will write a blog on the various functions of live templelates detailed introduction.
Continue to the first template, the lower left corner has a change button, you can click to specify the scope of the template.
The basic introduction is complete, look at the effect



The system provides a lot of templates and most of them are very useful, I do not list, you can view the live templates to find their own suitable use, the beginning may not adapt, after, you will find that you are getting faster.
Custom templates
After I learned about live templates, I found that I used to use Butterknife to write the onclick, but each time it was the same code, I can customize a template, see:



Customizes a group custom and defines a template with the abbreviation onclick under the grouping
The template content is a butterknife annotation decorated click Method, and a variable ID is declared.
Click Edit Variables as



An expression of Completesmart () is specified, indicating that the variable will be smart to complete the call (the cursor will appear in the variable position)
The specific results are as follows:



The resource ID for the activity is conveniently assigned here.

    • Little Tricks 1
      In using live templates if I'm writing code and writing for half an hour, I find that the shoe section of the code has been written several times and is likely to be written next. Do we copy and then open setting find live templates to add? You have a better choice!
      Select your code, click on the menu bar Tools->save as Live templates and then specify the abbreviation and other parameters to save.
      or open Settings Keymap, enter filter conditions live template, find Save as Live templates set shortcut keys
      [Image upload ... (24)]
      Here I set the Cmd+shift+s
      No need to order the menu, check the code directly cmd+shift+s
      [Image upload ... (25)]
      PS: Because I previously set the shortcut key, I thought there is a default shortcut key, want to see the default shortcut to write down, so point the next reset, found that this feature does not provide the default shortcut, and then the most tragic came, found that after reset I did not point to apply it is actually also effective, All the shortcuts I've modified have not been pulled .....
    • Little Tricks 2
      Join you want to use a template, but forget its initials, what to do now? Fast Cmd+j,windows computer I don't know, people set tricks 1 when you see an insert live templates, you can see the shortcut keys. This feature can prompt all templates that fit the current scene.
      Of course, there is a lot of knowledge of live templates, such as the definition of variables in the expression there are many, what each means, but these are not the focus of this article, so do not discuss.
Shortcut keys

Android Studio provides a very powerful shortcut key, personally feel that as long as you are familiar with the shortcut keys, from the moment you open Android Studio, you can throw the mouse ...
Personal frequently used shortcut key introduction
First, a wave of commonly used function shortcut effect demonstration, no diagram I also can not take the crowd ah (because many shortcuts here only to do part of the demonstration), PS: Here the shortcut is based on the shortcut key type as comes with, if you choose other shortcut type (such as Eclipse), you just need to open the settings, Keymap, Find the corresponding function by entering the filter criteria to see the shortcut keys.
The following format is
Describes/windows or Linux shortcut keys/mac shortcut keys
Introduced
Image

    • Find Action (F3/command + G)
      Find as all action functions (super Powerful)

    • Find Next (F3/command + G)
      Find the next

    • Find Previous
      Find Previous


    • Find Class (Control + N/command + O)
      Directly through the class name filter open class file, with this basic I rarely use the mouse to find class files.


    • Duplicate Current line or selection (Control + D/command + D)
      Quickly generate a single-line or selected copy of a row


    • Go to implementations (Control + ALT + B/command + ALT + B)
      Find the implementation of the current interface, or methods of implementation of the interface method, in the MVP mode is most commonly used


    • Extract method (Control + Alt + m/command + Option + M)
      Production of a method for the selection of code, super-intelligent, and even to know if you want parameters and return values, if there are multiple similar code, will be prompted whether to replace the unified, hanging to no friends.


    • Extract variable (Control + Alt + v/command + Option + V)
      Generates a temporary variable for the selected expression, if there are multiple places to prompt for a uniform replacement.


    • Extract Field (Control + Alt + f/command + Option + F)
      Generates a global variable for the selected expression, and if there are multiple places you will be prompted for a uniform replacement.


    • Next highlighted error (F2/F2)
      You must have been in a long code file to find an error, very troublesome, with this feature, the cursor moved directly to the wrong place.



      Space is limited, so much is introduced, other system shortcuts I sort out in tabular form, many features need to try to find its strong.

system default Shortcut keys

Listed in tabular form the system shortcut keys commonly used by individuals, PS: listed here are the system default shortcuts, if your shortcut key type is selected as Eclipse or other, you need to find the corresponding description to view or modify.

    • Normal type
Description explain Windows/linux Mac
Open Settings Dialogue Quick Open Settings Control + Alt + S Command +, (comma)
Open Project Structure Dialog Open Project Structure Control + Alt + Shift + S Command +; (semicolon)
Switch between Tabs and tool window TAB Toggle Control + Alt + Shift + S Command +; (semicolon)
    • Tracking and searching
Description explain Windows/linux Mac
Find Find Control + Alt + S Command +, (comma)
Search everything (including code and menus) Find All Click Shift two times to search Click Shift two times to search
Find Next Order down Search F3 Command + G
Find Action Find features, super powerful, as all features can be found through this feature Control + Shift + A Command + Shift + A
Find class Quickly find a class and open a file Control + N Command + O
Find file (instead of Class) Quickly find files Control + Shift + N Command + Shift + O
Find in Path Find all paths under the project Control + Shift + F Command + Shift + F
Recently opened files pop-up To list recently opened files F3control + E Command + E
Recently edited files pop-up List the most recently edited files Control + Shift + E Command + Shift + E
Go to last edit location Go back to the location of the last edit Control + Shift + Backspace Command + Shift + Backspace
Close Active Editor Tab Close the currently edited file Control + F4 Command + W
Open type hierarchy Open type Hierarchy relationship Control + H Control + H
Open Method Hierarchy Open a Method hierarchy relationship Control + Shift + H Command + Shift + H
Open Call Hierarchy Open Call Hierarchy Relationship Control + Alt + H Control + Option + H
    • Write code common shortcut keys
Description explain Windows/linux Mac
Generate code (getters, setters, constructors, Hashcode/equals, toString, new file, new Class) Quickly generate various methods Alt + Insert Command + N
Override methods Show all methods that can be overridden Control + O Control + O
Implement methods Show all methods that can be implemented Control + I Control + I
Surround with (if...else/try...catch/etc.) Quickly generate an if else,try catch for loop for statements, etc. Control + Alt + T Command + Option + T
Delete Line at caret Delete the cursor in the row Control + Y Command + Backspace
Duplicate Current line or selection Quickly generate a new current row, or a new multiline code Control + D Command + D
Quick Documentation Lookup Quick view of brief documents Control + P Command + P
Go to declaration (directly) Locate the variable or method declaration Control + B or CONTROL + Click Command + B or COMMAND + Click
Go to implementations Find an implementation class for an interface, where the interface method is implemented Control + Alt + B Command + Alt + B
Go to Super-method/super-class Find parent class or parent class method Control + U Command + U
Toggle Project tool Window visibility Show or hide the project window to the left of AS ALT + 1 Command + 1
Comment/uncomment with Line Comment Express single-line comment or remove comment Control +/ Command +/
Comment/uncomment with Block Comment Multi-line gaze or remove multiple lines of comment Command + Shift +/ Command + Shift +/
Project Quick fix (show intention actions and quick fixes) Give a variety of solutions to current problems (this method is very common) Alt + Enter Option + Enter
Reformat code Formatting code Control + Alt + L Command + Option + L
Next/previous highlighted error Find Next/Previous error F2/shift + F2 F2/shift + F2
    • Compile run
Description explain Windows/linux Mac
Build Compile Control + F9 Command + F9
Build and run Compile Shift + F10 Control + R
    • Debugging
Description explain Windows/linux Mac
Debug Shift + F9 Shift + F9
Step over F8 F8
Step into F7 F7
Smart Step Into Shift + F7 Shift + F7
Resume Program F9 Command + Option + R
    • Modify
description explain windows/linux Mac
Safe Delete safe Delete Alt + DELETE Command + DELETE
Extract Method Extract Methods Control + Alt + M Command + Option + M
Extract Method Extraction Methods Control + Alt + v Command + Option + v
Extract variable extract variable Control + Alt + v Command + Option + v
Extract Field extract global variables Control + Alt + F Command + Option + F
Extract constant Extract constant Control + Alt + C Command + Option + C
Extract parameter extract parameters Control + Alt + P Command + Option + p
    • Version Control/Local History
Description explain Windows/linux Mac
Commit Project to VCS Control + K Command + K
Update Project from VCS Control + T Command + T
View Recent Changes View Recent Changes Alt + Shift + C Option + Shift + C
Open VCS Popup Open the Version Control Settings window Alt + ' (backquote) Control + V
Extended
    • Custom shortcut keys
      See here to believe that we have a deeper understanding of the shortcut keys, we can achieve a powerful function through a few keys, but sometimes many of the system provides shortcut keys and your own system shortcuts may conflict, or some powerful function as does not provide you shortcut keys, This involves the customization of the shortcut keys (modified or added).
      For example, the above mentioned find and highlight the error code as provided is the F2 key, but on the Mac is the function key and I want to keep, I modified in order to command+shift+2
      About the shortcut key customization I will not mention, we have a lot of Baidu article.
    • Discover more versatility
      KeyMap listed in a number of functions, space and Energy Limited, can not be listed, you have time to open the set->keymap, to see the shortcut keys inside, unsure of their own personally pressed to try, you will find that the original can be so convenient.
Android Studio Plugin

1. Debug your phone via WiFi:Android wifi adb, adb wifi
2.ButterKnife Annotation Generator:Butterknife Zelezny
3.Selector file generation:Selectorchapek
4.Gson Automation:Gsonformat
5.Parcelable Automation:Android parcelable Code Generator
6. Generate Viewholder and Findview methods:Androidcodegenerator
7. Lines of code statistics:Statistic
8. Code Search:Codota
9. Simulator:Genymotion
10. Quickly write code for log, Toast, IsEmpty:Postfix
11.Android Studio Translation plugin, can be translated into Chinese English:Ectranslation:https://github.com/skykai521/ectranslation
12. Can be used to quickly locate the code:Codeglance
13. The life cycle method location can be sorted according to activity or fragment life cycle:Lifecycle Sorter
14. Help you find hidden bugs and bad practices through FindBugs:Findbugs-idea
15. The site collects a lot of code, claiming that more than 700W of code examples:Codota
16. Check the code-style plugin:Checkstyle-idea
17. A plugin for API 23 that can quickly generate runtime permissions code in Activity/fragment:Permissionsdispatcher
18. Create a plugin for material Design icon:Android Material Design Icon Generator
19.Material Theme color scheme:Material Theme UI
20.Android Efficient Development debugging artifact:jrebel:https://zeroturnaround.com/
21. Known as the Android platform for the second-level compilation scheme:Freeline:https://yq.aliyun.com/articles/59122?spm=5176.8091938.0.0.1bw3mu

Install Plug-in method: open File, Settings, Plugins, Browse repositories, enter the plug-in name search, directly click "Install" installation. If the search is not available to download it here, select "Install plugin from disk" for offline installation.

Android Studio shortcuts and handy plugins

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.