Practical shortcuts in Android programming

Source: Internet
Author: User

As a good programmer, not only to develop beautiful software, but also to master the skills of programming, including the IDE's shortcut keys. such as the VI editor under Linux, for unskilled shortcut keys is a nightmare, but once you become proficient in the VI shortcut, VI efficiency will be higher than with the mouse editor. Even VI to reduce the time dissipation of the finger switching between the main keyboard area and the arrow keys, directly set the direction key to HJKL, it is obvious how important the programmer's meaning is to use the skilled keyboard.

Android's officially recommended development platform Eclipse is a very powerful IDE environment with hundreds of shortcuts that make it easy for Android developers, but it's hard to get it all quickly. Here, I summed up my own in the Android programming often used in more than 10 shortcut keys, here to share, I hope to help you.

1. Text editing

Editing text lines is the basic skill of programming, the common shortcut keys are as follows:

(1) quickly move to the end of the wardrobe line. Eclipse often is the right parenthesis and then write the parentheses in the parameters, after writing, if the move to control the mouse is too slow, the shortcut to this is the home cursor transition Head,end cursor transitional tail. In addition, you can use enter to migrate the tail after using automatic completion .

(2) Delete the current line. In addition to programming needs, eclipse often automatically generates some comments and blank lines, if you want to delete the cursor line, you can use the shortcut key ctrl+d.

(3) Copy the current line. When developing the Android declaration variable, sometimes the next few lines of code are one or two letters different, when copying the current line is useful, ctrl+alt+↓ copy the current line to the following line, in the samevein,ctrl+alt+↑ copy the current line to the previous row. It is necessary to note that this shortcut key in Ubuntu with the workspace switch conflict, the proposed changes to ctrl+↑, modify methods and illustrations will be given.

(4) Insert a blank line in the previous line or the next line. This is not much explained, insert a row below with shift+enter, insert a row above with Shift+ctrl+enter.

(5) Regret medicine. Before returning to the changes, this many software is the same as Ctrl + Z.

(6) Code formatting. If you like to copy code from the Internet to run or read, then use this to use blessing, you can format the code in Eclipse format, shortcut key is ctrl+shift+f.

(7) The upper and lower two lines of exchange position. You can swap the position of the upper and lower lines, or the selected lines with the upper and lower line, and the shortcut key swapped with the previous line is alt+↑, and the shortcut key swapped with the next line is alt+↓.

2. Android Programming shortcut keys

(1) The most classic smart tips. The Android API is long and difficult to remember variables and functions, smart tips can be input point operators, provide functions or the first few characters of a variable to complete or provide candidates, can be said to be the most useful in the development of Android shortcut keys, its use is alt+/. For example, when registering a control, you can get Findviewbyid () by knocking only one F and then alt+/. Again, just typing sysout, then alt+/, you can get System.out.println ().

(2) Global Save to check for XML errors and provide resources. Eclipse does not check syntax errors in real time when writing XML documents, and Eclipse does not provide you with smart hints if you write resource, layout-related information that is not saved. So it's recommended to write some of these types of information and save them with the shortcut key Crtl+shift+s, one to check for XML errors, and to tell Eclipse that you have provided these resources.

(3) Import the package. We use the SDK provided by the class, even if it is a button, will be error, because you do not import the package, you can use Ctrl+shift+o in any row can be imported to import the package, OK.

(4) Implement virtual methods. When we inherit certain base classes or interfaces, eclipse will make an error because we do not have virtual methods to implement these classes and interfaces. Move the cursor to the place where the error picture red Line, using the quick fix shortcut key ctrl+1, in the pop-up menu, "Add unimplemented methods", you can get the virtual method to be implemented.

(5) Rename the parameter. If you need to rename the object you define, it is too out to find and modify it. You can move the cursor to the reference (object name), press Alt+shift+r (R Press two), write a new reference name in the popup dialog box, the following two options, the second tick will modify the comments and the string content, so generally only select the first, modify the reference.

(6) The Replication method (override). An important feature of object-oriented is that subclasses can reuse the methods of the parent class, so the method of calling the parent class is often used. In fact, the shortcut key is also alt+/, in the class body in the appropriate blank line will come out, but because the replication operation is very important, so specifically written out.

Android programming commonly used shortcuts introduced here, if you find in the actual programming key conflicts or use too limp hand, you can edit the appropriate shortcut keys. Finally, the settings for shortcut keys are described here. Click Window→preferences→general→keys to open the edit page and set it up.

Not only do you want to edit the shortcut key combinations associated with the command, but also choose when to work, such as Editing Text (valid when editing a document).

Practical shortcuts in Android programming

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.