The fastest way to develop Android studio

Source: Internet
Author: User
Tags try catch

Overview

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 Introduction

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 Introduction

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

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

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 vaR Iabl e To define the variables, the templates defined in the n a Span class= "Mi" id= "mathjax-span-15" style= "font-family:stixgeneral; Font-style:italic; " >m e 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 and click on the menu to stop Tools->save as Live templates
Then directly 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

Here I set the Cmd+shift+s

No need to order the menu, check the code directly cmd+shift+s

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
Find Action
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 removal Alt + Delete Command + Delete
Extract method Extraction method Control + Alt + M Command + Option + M
Extract method Extraction method Control + Alt + V Command + Option + V
Extract variable Extracting variables Control + Alt + V Command + Option + V
Extract Field Extracting Global variables Control + Alt + F Command + Option + F
EXTRACT constant Extracting constants Control + Alt + C Command + Option + C
Extract parameter Extracting 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
Extend 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's list of features, space and energy is limited, can not be listed,
When you have time, you can open the settings->keymap, to see the shortcut keys inside, not sure you personally press the test, you will find that the original can be so convenient.

Plug - ins

Here are recommended a few personal use in the feel really good plug-ins, these plug-in introduction articles are many, I do not detail.

Android Butterknife Zelezny

It can be easily and quickly initialized, eliminating the tedious operation of FindByID and so on.

Gsonformat

Java entity classes can be generated quickly based on JSON data.

Android Material Design Icon Generator

Quickly generate material design icons, for students who are less demanding in small companies, can easily generate the right icon.

Android Wifi ADB

is not very annoying debugging always put the phone next to the computer, with this plugin you can not be next to the computer debugging.

Due to the time relationship, the plug-in diagram is not made, the above two images address source: http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/1009/3557.html

Tip of the day

Do not know if you have noticed, every day when you first open the Android studio, always first pop up a dialog box, I believe most of the students are determined to close and start today's work, guessed to give me some praise!haha

Tip of the day will recommend you some of the skills of using Android Studio, shortcut keys and so on, so I hope you can take a minute to see, a daily accumulation, six months after a year you are the king of the development of efficiency!

You can select Help->tip of the day from the menu at any time to view

Conclusion

Spent a weekend to summarize the rapid development here to the end, because of time, there must be many aspects of insufficient or not mentioned, please forgive me! This article will continue to update, like my article, Welcome to follow me!

Like just a second, the momentum is indeed eternal, point a praise Bai!

I have just opened the public number, at least two articles a week, starting next week, welcome to my public number.

The fastest way to develop Android studio

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.