Android Studio 添加註解模板,解決辦法。
阿新 • • 發佈:2019-02-04
最近在從Eclipse的開發環境中轉移到Android Studio 的開發當中,
遇到了,Android Studio 對類和方法註釋模板的設定問題。
方法1:
Class類的標頭檔案進行配置Header 註釋,
方法:File >> Setting >> File and Code Templates--Includes--File Header,
Class類方法,變數的註釋
方法:只能使用 (File -> Settings -> Keymap,搜尋 fix doc comment,設定快捷鍵)進行快速插入
方法2:
安裝外掛:
選擇Setting =>Plugins=>Browse repositories,搜尋Eclipse即可出現,點選左上角的Download and Install安裝。安裝之後重啟Intellij,即可在Setting =>Eclipse Code Formatter找到配置項。
配置外掛:
選擇Setting =>Eclipse Code Formatter,勾選Use the Eclipse-code-formatter,並在Eclipse Java Formatter config file選擇Eclipse用的code-style.xml檔案,這個選項會決定格式化程式碼的方式。同時配置Import order的From File也為Eclipse用的code-style.xml檔案,這個選項會決定組織import區域的方式。
使用外掛
使用Intellij的格式化快捷鍵"Ctrl+ALT+L"即可進行格式化。如果出錯會輸出提示到Event Log裡,如果看到'xxx formatted sucessfully by Eclipse code formatter'則表示格式化成功!
補充一個小技巧,一般建議只格式化自己的程式碼,不進行全檔案格式化,選擇自己的程式碼塊再使用"Ctrl+ALT+L"即可部分格式化。
轉自:http://my.oschina.net/flashsword/blog/137598#
參考:http://blog.jetbrains.com/idea/2014/01/intellij-idea-13-importing-code-formatter-settings-from-eclipse/