android學習:android開發常見技巧設置,提高開發效率

一. 智能提示

在下圖位置,添加   .abcdefghijklmnopqrstuvwxyz(,    實現開發過程中 對java代碼和xml文件更快捷的智能提示。

二. Eclipse包摺疊視圖




三、修改默認編碼爲UTF-8


參考:http://blog.csdn.net/pdw_jsp/article/details/6212896
1、windows->Preferences...打開"首選項"對話框,左側導航樹,導航到general->Workspace,右側 Text file encoding,選擇Other,改變爲UTF-8,以後新建立工程其屬性對話框中的Text file encoding即爲UTF-8。
2、windows->Preferences...打開"首選項"對話框,左側導航樹,導航到general->Content Types,右側Context Types樹,點開Text,選擇Java Source File,在下面的Default encoding輸入框中輸入UTF-8,點Update,則設置Java文件編碼爲UTF-8。其他java應用開發相關的文件如:properties、XML等已經由Eclipse缺省指定,分別爲ISO8859-1,UTF-8,如開發中確需改變編碼格式則可以在此指定。

四、代碼塊摺疊 com.cb.eclipse.folding(類似Visual Studio的#region ...#endregion 


參考:
http://www.cnblogs.com/haiq/archive/2011/06/22/2087069.html
http://my.oschina.net/axes/blog/124714

代碼摺疊默認快捷鍵:
<span style="font-size:18px;">    Ctrl+Shift+Numpad_Divede(小鍵盤的/號)
    Ctrl+Shift+Numpad_Multiply(小鍵盤的*號)</span>

2. 將壓縮包中的 com.cb.eclipse.folding_1.0.6.jar 放到 eclipse\plugins 目錄下,重新啓動 eclipse.
3. 啓動eclipse後,進入 window->preference 菜單選項,在配置窗口中選擇 java->editor,select folding to user 中選擇"Coffee Bytes Java Folding",保存後重啓 eclipse 。
4. 重啓之後再次進入步驟2,勾選最後一個 User Defined Regions, 保存後即可。(當然可以在User Defined Regions自定義摺疊方式)



五、get/set方法自動加上字段註釋

參考:http://blog.csdn.net/manageer/article/details/9028891

1. 找到Eclipse目錄下搜索找到org.eclipse.jdt.ui_*.jar(*是版本號),進行備份

2. 將jar文件改成.rar格式並使用壓縮軟件打開。

3. 找到\org\eclipse\jdt\internal\corext\codemanipulation這個目錄下的GetterSetterUtil.class這個文件。反編譯修改getSetterStub 和 getGetterStub 方法,修改如下,或者直接使用(此鏈接文件)替換(記得要備份喔)

if (addComments) {
	//field.getCompilationUnit() 得到當前類文件內容,就是要get,set的東西
	//parentType.getTypeQualifiedName('.') 得到類名
	//getterName 拼出get的方法名
	//field.getElementName() 得到字段名
	//typeName 類型
	String comment= CodeGeneration.getGetterComment(
			field.getCompilationUnit(),
			parentType.getTypeQualifiedName('.'),
			getterName,
			field.getElementName(),
			typeName, 
			accessorName, 
			lineDelim);
	ISourceRange sr = field.getJavadocRange();
	  if( null != sr ) {
		  String filedComment = field.getSource();
		  filedComment = filedComment.substring(0, sr.getLength());
		  filedComment = filedComment.replaceAll("[\n,\r,*,/, ,\t]", "");

		  comment = comment.replaceFirst(field.getElementName(), filedComment);
		    
		  int i = comment.lastIndexOf(field.getElementName());
		  int j = getCount(comment, field.getElementName());
		  if (i != -1 && j >= 2) {
			  comment = comment.substring(0, i) + filedComment + comment.substring(i + field.getElementName().length());
		  }
	  }
	  
	if (comment != null) {
		buf.append(comment);
		buf.append(lineDelim);
	}
}

4. 開啓開發工具找到Window->Preferences->Java->CodeStyle->Code Templates->Comments->Getters/Setters

  getters:

[java] view plaincopy
  1. /**   
  2.  * 獲取${bare_field_name}   
  3.  * @return ${bare_field_name} ${bare_field_name}   
  4.  */    
setters:

[java] view plaincopy
  1. /**   
  2.  * 設置${bare_field_name}   
  3.  * @param ${bare_field_name} ${bare_field_name}   
  4.  */    

注意:生成Get/Set方法時勾選上Generate method comments

六、其它設置

  1. 設置字體大小:Window->preferences->General——Appearance——Colors and Fonts——Basic——Text Font——Edit
  2. 顯示行號:Window->preferences->General——Editors——Text Editors——Show  line numbers
  3. 保存的時候,自動格式化代碼:Window->preferences->java——>editor——>Save Actions
  4. 設置自定義代碼代碼風格:窗口→首選項→Java→代碼樣式→格式化程序→新建
  5. 設置註釋模板:Window->preferences->java->code style ->code templates ->Comments ->typese->edit->

/**
 * @author 付亮
 * @date ${date}${time}
 * ${tags}
 */
或者在:在eclipse的安裝路徑下,打開eclipse.ini的配置文件

在-vmargs下加入:

-Duser.name=你的名字



雲天博客:http://www.yuntianseo.com   專注於網絡營銷推廣!   更多草根創業資訊瞭解:雲天博客
發佈了86 篇原創文章 · 獲贊 12 · 訪問量 42萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章