Use Eclipse efficiently and use Eclipse
To do their best, you must first sharpen your tools.
As an Android programmer, Eclipse should be your first IDE To get started. Of course, you can also choose the legendary artifacts:Android Studio
OrIntelliJ IDEA
. The difference between Eclipse and these new promotion artifacts is not discussed here (Portal: Where is Android Studio better than Eclipse ?), We simply focus on Eclipse and how to improve our work efficiency.
Set your File Encoding
For many children's shoes, no settings are set.File Encoding
The habit, and its comments are often Chinese notes, In order to our notes can be normal display in other people's machines, to prevent garbled breeding, Please modify the text encoding method for UTF-8.
How to Set: Window → Preferences → General → Workspace → Text file encoding, setUTF-8
Font selection
Every programmer has a set of his/her favorite programming fonts. For those who pursue perfection in their senses, a set of good fonts can usually minimize your programming attention. Generally, the default Eclipse font isCourier New
The font no. 10 looks good, but we have a better font to choose from. Both English and Chinese are perfect, that isConsolas
The font size is 11.
How to Set: Window → Preferences → General → Appearence Colors And Fonts. In the dialog box on the right, select Java-Java Editor Text Font to set the programming Font. Of course, the font of the dialog box can also be set here.
For more perfect programming fonts, see: 10 optimal programming Fonts
Finally, we recommend an equal-width font that is open-Source by Adobe: Source Code Pro, which is very beautiful.
Theme
If you are tired of changing the font, text color, and other complex things, we still have a unified solution, that isEclipse Color Theme
Plug-ins, which can provide you with many very beautiful themes, such as Sublime Text 2, Obsidian, Notepad + + Like, and so on. They are sufficient to meet the needs of various groups of people, it is powerful: Eclipse Color Themes
How to install:
Step 1: InstallMarketplace
: Http://download.eclipse.org/mpc/indigo/
Step 2: PassMarketplace
Install this plug-in
Of course, you can also directly Install this plug-in by clicking Help → Install New Software in Eclipse. For more information, see Google.
JAVA
Intelligent Sensing is undoubtedly the most direct way to accelerate programming. By default, when writing a JAVA program.
Or manually PressAlt+/
Eclipse will display the code prompt, which is very inconvenient. How can I display the prompt box with any characters?
How to Set: Window → Preferences → Java → Editor → Content Assist. Set Auto activation triggers for java:
.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW_(
In addition, to accelerate the trigger time of the smart prompt box, we set Auto activation delay (MS)20
After setting:
XML
Android programmers often need to write XML layout files, but the headache is that there is no intelligence in XML, and only<=:
Intelligent prompt box. How can this problem be solved?
In fact, the solution is the same as setting JAVA's smart awareness.
How to Set: Window → Preferences → XML files → Editor → Content Assist → Auto Activation, set Prompt when thiese characters are inserted:.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_(<=:
And set Auto activation delay (MS)20
After setting:
# And @
Most lazy people and those who do not like to write comments complain that comments are hard to write and are too easy to distribute. As a programmer, if you are too lazy to write comments, I personally think this is a very irresponsible programmer, because 80% of the software life cycle is spent on maintenance, and the consequence of not writing comments is serious, it greatly increases the difficulty of software maintenance... Is it really hard to write a comment? As for how to write professional comments, I will not give too many explanations, but provide two simple skills.
Tips for adding comments to code: Use@#
ActivateJavaDoc
@: Add keywords in the document
/*** This class is the entrance of the entire DEMO program. ** @ Author XXX * @ date 2013-09-29 */public class DemoMainActivity extends Activity {
#: Add code Link
/** * Calls {@link android.view.Window#getCurrentFocus} on the * Window of this Activity to return the currently focused view. * * @return View The current View with focus or null. * * @see #getWindow * @see android.view.Window#getCurrentFocus */public View getCurrentFocus() { return mWindow != null ? mWindow.getCurrentFocus() : null;}
Shortcut Key
The importance of shortcuts is unnecessary. To speed up coding and read code efficiency, I think everyone should master the following commonly used shortcuts. If you forget the shortcut key, you can useCtrl-Shift-L
Open the shortcut key window.
Eclipse shortcuts required for studying code
10 most useful shortcut keys for Eclipse
Integrate SVN with Beyond Compare
It is a good way to integrate SVN into Eclipse, so we don't have to switch from the Windows folder. In the early days, I had never trusted this SVN plug-in because I felt I was using it directly.TortoiseSVN + Beyond Compare
It will be even better. The comparison tools provided by the SVN plug-in are too bad, and it is extremely uncomfortable to compare the code.
SVN plug-in selection
There are currently two good plug-ins on the market:
-Subversive (officially released by the Eclipse Team)
-Subclipse (officially produced by the SVN Team)
The advantages and disadvantages between them can be viewed in this article: Subclipse vs Subversive
Select YesSubversion
, Because it andBeyond Compare 3
Easier configuration,Subclipse
I configured it for a long time.
How to install the Subversion plugin:
-Directly from the EclipseMarketplace
Install On
-PassHelp → Install New Software
Install this plug-in
Http://community.polarion.com/projects/subversive/download/eclipse/3.0/juno-site/
In addition, when using SubversionSVN Connector
SelectJavaHL
(Note the version selection)
Configure Beyond Compare 3 in SVN
If you get used to the BeyondCompare file comparison style and use the SVN native comparison style, you will feel extremely painful. Therefore, we need to make BeyondCompare able to be configured in the SVN plug-in.
How to configure:
Step 1: Window → Preferences → Team → SVN → Diff Viewer
Step 2: ClickAdd
, Set the file type to any file, that is, inExtension or mime-type
Add*
Step 3: select the Beyond Compare file path (add the path with double quotation marks ),
Set parameters in Diff:"${base}" "${mine}"
Set parameters in Merge:
"${theirs}" "${mine}" "${base}" "${merged}"
/lefttitle="Incoming (${theirs})"
/centertitle="Base (${base})"
/righttitle="Local (${mine})"
/outputtitle="Merged (${merged})"
:
Java Code Style Configuration
The various configurations of Java Code Style mainly refer to the Code specifications of our Code, such as line breaks, spaces, and comments.
In Window → Preferences → Java → Code StyleClean Up
,Code Templates
,Formatter
In general, a team needs to have some uniform style templates to unify the encoding style. The following three links are a template I have made for your reference only.
-Clean Up
-Code Template
-Formatter
How to Use: Save the above three filesFormatterFor exampleFormatter
Interface, clickImport
Import. The other two are similar.