2015-05-27 99 views
2

有沒有辦法如何添加評論/說明/文檔到android資源參考?我知道的唯一方法是使用標準的XML評論。這顯然不理想。Android的JavaDoc XML(字符串)資源

喜歡的東西特殊屬性或特殊的Javadoc預先元件

<resources> 
    <string documentation="Some useful information what does this resource means..." name="KEY" translatable="false">value</string> 
</resources> 

<resources> 
    <documentation forName="KEY">Some useful information what does this resource means...</documentation> 
    <string name="KEY" translatable="false">value</string> 
</resources> 

不理想,但目前實用的方法:

<resources> 
    <!-- Some useful information about what this resource means... --> 
    <string name="KEY" translatable="false">value</string> 
</resources> 

回答

0

以下格式允許一個文件報頭(使用XML文檔註釋),以及作爲隨每個資源條目一起提供的單獨評論(文檔屬性)。我沒有編譯器抱怨需要包含documentation的特定名稱空間(xmlns:tools除外)。

<?xml version="1.0" encoding="utf-8"?> 
<!--============================================================================================= 

My File description here 

==============================================================================================--> 

<resources xmlns:tools="http://schemas.android.com/tools"> 

    <string name="Application_Name" documentation="Name of the application. Used as Activity Name as the title, and appears in About box">FantasticApp</string> 

</resources> 
+0

感謝,文檔屬性的作品。但它仍然沒有集成到androidstudio show-javadoc-autocomplete功能中。這是好的中間步驟。 – Wooff