Android Studio tips series (1)

Source: Internet
Author: User

Android Studio tips series (1)

 

You should know the following two points about me:
1. I am an IDE enthusiast
2. I am an efficient geek
Two years ago, when I switched to Intellij IDEA and Android Studio, I spent a lot of time searching for shortcuts and technologies for more efficient development. When you see this article, I believe you have done a lot of the same thing, so for you, I try to make it easier and faster.

In this series of tutorials, we will learn from the most basic development skills that every developer should know to more advanced skills in Android Studio.

Key-bit ing
Android Studio provides different key-bit ing (that is, the ing between the shortcut key and its corresponding operations). You can view the currently used key-bit ing in the "Settings-> Keymap" menu.
Listing each key-bit ing is not practical, so the following will be used:
Windows: Default
Linux: Default
OSX: Mac OSX 10.5 + (not the default one. We strongly recommend using Jetbrains)

Redirection
We spent a lot of time on code jump, so we tried to improve its efficiency.

Open a class
OS X: cmd + o
Windows Or Linux: ctrl + n
If you have to jump to a class named "MainActivity", you only need to use this shortcut key and enter "MainA.

Open a file
OS X: cmd + shift + o
Windows Or Linux: ctrl + shift + n
The shortcut key is similar to the preceding one, but it acts on all files in the project. It is very useful for opening AndroidManifest. xml or files in the res/and assets/folders.

Open a symbol
OS X: cmd + alt + shift + o
Windows Or Linux: ctrl + alt + shift + n, cannot be verified without Mac)
A powerful one, but a little different from the previous one: you can jump directly through the search method or variable name.
For example, you know that there is a method named getFormattedDate () somewhere in the project. You can use this shortcut to find it directly.

Tips

Partial match
You can enter some characters and match them. For example, if you want to find a class named "ItemDetailFragment", you can only enter "IDF" to find it.

Row number
If your colleague only tells you that a code is in the 22 rows of the ExcitingClass class, you can use the shortcut key to open a class to append a ":" (colon) to the end of the class name ), enter the row number at the end, for example:
ExcitingClass: 22
You can also use partial matching in hybrid mode, as shown in the following figure:
EC: 22

Recently opened files
OS X: cmd + e
Windows Or Linux: ctrl + e
A list of recently opened files is displayed.

Recently edited File
OS X: cmd + shift + e
Windows Or Linux: ctrl + shift + e
Similar to the above functions, but only the modified ones are listed.

Tips

The input characters can be used to filter the list.

Forward or backward
OS X: cmd + alt + left/right
Windows Or Linux: ctrl + alt + left/right
To better understand this shortcut key, you should think about how the WEB browser goes forward and backward. It is not on the web page, but in the source code! Therefore, when you jump into a code or open a new file, IDE will remember your previous location and return quickly.

Last edited location
OS X: cmd + shift + backspace
Windows Or Linux: ctrl + shift + backspace
This is different from the preceding shortcut key. It redirects between the last modified code location.
Imagine you are modifying an annoying bug. You think you can solve it and start to fix it, but when you realize that you have to look at the android source code and other classes in your project, you enter a function of other classes, after another 20 steps in other files, you finally completed your repair, but what line did you edit? You can use this shortcut to return the result correctly.

Display usage
On a fixed panel
OS X: alt + F7
Windows Or Linux: alt + F7
Display the places in use. For a class member variable, it will display the used places (read and write ). For a method, it will display the called place. For a class, it will display where the instantiation is created.
You can use the arrow keys and return keys to view the results. Then, you can use "Esc" to return to the editing window.

Show where to use 2
OS X: cmd + alt + F7
Windows Or Linux: ctrl + alt + F7
As shown above, it is displayed in the pop-up box.

Jump to declaration or implementation
There are three shortcut keys for entering a symbol:

Jump to Declaration
OS x: cmd + B
Windows Or Linux: ctrl + B
OS X: cmd + click
Windows Or Linux: ctrl + click
Jump to a class, method, or variable declaration. It is useful to jump to the implementation of classes and methods.

Jump to implementation
OS x: cmd + alt + B
Windows Or Linux: ctrl + alt + B
Lists all the classes/interfaces selected by classes/interfaces. You can also find implemented/overriden in the method. The variable will jump to the declared place.

Jump to type declaration
OS x: cmd + shift + B
Windows Or Linux: ctrl + shift + B
When the cursor is on a variable, it jumps to the declaration of the variable type. For example, the following line of code:
Developer phil = new Developer ("Phil ");
If the cursor is on the "phil" variable, pressing the shortcut key will jump to the declaration of the "Developer" class.

Jump to parent class
OS X: cmd + u
Windows Or Linux: ctrl + u
This will open the current symbol of the parent class. This is the opposite of the function to be implemented. If the cursor is on a method to be overwritten, it will open the implementation of the parent class. If the cursor is outside a class method or a class name, it opens the parent class.

That's all!
 

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.