An explanation of Android Studio development Tips

Source: Internet
Author: User

Android Studio Development tools every Android app is a tool that apes use every day, but even if you're an experienced developer, you've probably missed out on a lot of life-saving tricks, and this article might help you get a handle on some of them. I will not translate word, but in the most concise and understandable way to introduce to you, while providing the necessary annotations and extensions, so that you can quickly read after a quick grasp.

1.When you can't remember how a feature is used

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" > If you are  windows/linux  user ,   Ctrl + Shift + a if you are   Mac   user, then press Command + Shift + a gradle   offline work   offline Toggle Offline work Auto Import function, then just enter in the input box. Auto import then select the corresponding item.

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" > 2, modify shortcut keys

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" >  android studio  Ctrl + Shift + a keymap, select the Settings > Keymap the option to see all the fast keys here, it is not recommended to modify the shortcut keys directly on the original shortcut key scheme. Instead, copy an existing scheme and change it, and in the keymaps default Copy Add Keyboard shortcut and then you can set your favorite shortcut keys, if you set the shortcut keys and other keys conflict, will be red error message prompts.

because of the number of shortcut keys in the list, we can also use the search box on the right to search, for example, we need to modify the basic auto-completion of the shortcut keys we just enter Basic, you can find the corresponding item in the results.

3, you need to understand the automatic completion

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" >  android studio  Log. LOG.D (), LOG.E, log.i () log.d () LOG.E () You're not going to put . E () Delete, and then enter a .

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" > Ctrl +  spaces, however   windows  users are unhappy because of this and   windwos  system Toggle Input Method shortcut key conflict, if you do not want to modify this shortcut, then use Ctrl + Alt +  space as an alternative, if you want to modify this quick key, then you can use the method of the previous section to set a new shortcut, in the Keymaps interface search Basic code->completion->basic Ctrl + Shift +  spaces ,  But Smart complements are much more than that, and when you call a method, you can use smart completion to associate a variable in the current context with the parameter type of the method.

4. replace the current method or value with the Tab key after auto prompt

If we manually exhale the auto-completion, the current position already has a corresponding method or variable (such as the original call OBJ 's a method, then we put the cursor to The location of the A method, call out auto-completion, want to auto-complete the B method instead of A method), this time if we select the completion of the item, press ENTER, Then the completion of the content will be inserted in front of the original content, this is not what we want, in fact, should not press ENTER, but Tab.

5. When you have finished writing a line of code

This is a very common situation, when you finish writing a line of code, the cursor is not at the end of the current line, the more common is the right side of the cursor and N A closing parenthesis, what will you do? You may use the arrow keys to move the cursor to the end of the line, and then manually enter one ; . In fact, there is a simpler solution, that is , Ctrl + Shift + Enter, this shortcut will help you automatically complete the current expression of the missing parts, including at the end of the input ; , it is worth mentioning that the shortcut key is also valid for the IF,else,for, and while control loops.

another situation where the cursor is not at the end of the line, but you want to be able to insert a blank row in the next line, Shift + Enter can help you complete this task.

6, three tips for positioning

using 4 arrow keys to position the cursor is the most familiar method, but it can be more convenient. Hold down CTRL while pressing the ARROW keys , you can move one word at a time, press and hold ALT while pressing the up and down keys, and you can move one node (method or field) by one node; If you hold down SHIFT + Ctrl while pressing the up and down keys , you can swap positions between the current row and the upper and lower lines.

7. Automatically generated code template according to suffix

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" > If-else, For  And so on, using code templates can help us generate the desired code much faster. For example, first enter a variable of the collection type and add the suffix . Fori For loops, in the same way, expressions of the Boolean type plus . If if statement.

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" > intellij Android Studio  also offers many and   android  toast parcelable Ctrl + Shift + a call out the universal search box, enter Live Templates, select the settings Live templates

< Span style= "FONT-FAMILY:CALIBRI;FONT-SIZE:16PX;" > 8, debug  How to customize the display of objects

When debugging code, we often need to look at the value of an object. Especially the custom object, we often do not implement its toString method, then this object in the IDE 's value is classname:hashvalue this way. We need to open this object to see the values of each member within it. There is a better way to do this without implementing the ToString method. In the debug Variable window, right-click the object you want to view, and select view asto set how the object will be displayed in the Debug state.

Article Source: Dark Horse Programmer

An explanation of Android Studio development Tips

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.