Android Studio shortcut key daily (6)

Source: Internet
Author: User

Original address: http://www.developerphil.com/android-studio-tips-of-the-day-roundup-6/

51. Refactoring Code

Apple: Ctrl+t windows:ctrl+alt+shift+t

The shortcut will give a list of refactoring options for the selected code based on the current context. This list can be retrieved from the keyboard, or it can be quickly selected using the numbers on the left side of the list.

52. View recently changed files

Apple: Cmd+shift+e windows:ctrl+shift+e

This shortcut lists the list of recently modified files, usually the most recent of which is at the top of the list. In addition, this list can be filtered by entering keywords.

53. View Associated Files

Apple: Ctrl+cmd+up windows:ctrl+alt+home

This can help you to easily jump between XML layout files and activity/fragment. There is also a shortcut icon on the left side of the edit area, which you can click to view.

54. Extracting variables

Apple: Cmd+alt+v windows:ctrl+alt+v

This approach allows you to extract related variables directly using shortcut keys instead of the menu to choose Refactoring. When you generate code dynamically, this shortcut can even allow you to enter variable values directly without having to enter a variable declaration, and the IDE will take care of all of this and give some suggestions on how to properly name variables.

More tips:

(1) If you want to change the variable declaration type or the generic type, you can enter the Shift+tab combo pop-up list to select it.

55. Extracting variables as method parameters

Apple: Cmd+alt+p windows:ctrl+alt+p

This shortcut is easy when you realize that some variables need to be extracted as parameters of the method. When a variable is extracted, it takes the variable name as the parameter of the method, and the original value of the variable is passed as an argument to the caller of the method.

More tips:

(1) You can also generate a new proxy method by selecting the "Delegate" box, and the original method will invoke the proxy method to implement the logic.

56. Extraction Method

Apple: Cmd+alt+m windows:ctrl+alt+m

The effect is very simple, that is, a block of code is stripped out as a separate method. When a method becomes more and more bloated, this method can safely and quickly separate blocks of code into a new method. The reason for security is that the IDE does not make all kinds of copy and paste mistakes like people do.

More tips:

(1) You can modify the scope and parameter name of the method in the Extract Method dialog box.

57. Inline code

Apple: Cmd+alt+n windows:ctrl+alt+m

Does it feel helpless or hard to remember the various methods of extracting refactoring? Inline code allows you to relieve the nerves. This function is useful for methods, domain variables, method parameters, and temporary variables.

58. Renaming

Shortcut key: Shift+f6

Use this shortcut to rename temporary variables, domain variables, methods, classes, and even package names. This feature is not a simple find-and-replace, it takes the renaming into effect based on the context of the project.

More tips:

(1) If you can't remember this shortcut, you can also use quick fix to include the name refactoring feature in the shortcut.

59. Promotion class member or drop-down class member

Apple: Press and hold ctrl+t and select pull Members Up/push

Windows: Press and hold ctrl+alt+shift+t and select pull Members Up/push

When we talk about Ascension, we are actually saying that the class member (usually a domain or method) goes from the current class to the parent class or to the interface that implements it. In the case of a parent class, the class member is moved to the parent class as a whole, and if it is an interface, the promoted method is declared in the interface. This method is preserved in the current class, plus @override annotations. The drop-down member is the opposite of the promoted member.

Android Studio shortcut key daily (6)

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.