2013-12-09 40 views

回答

10

我有同樣的問題,因爲我已經對SDK進行了更新。我找到了解決這個問題的方法。只需在您的string.xml文件中的每個字符串之前添加註釋,這將解決警告。下面

例子:

<!-- Description here --> 
<string name="app_name">Test App</string> 
+0

因爲沒有評論來描述每個字符串,所以是警告嗎?可怕!我會盡力的,謝謝! – HAL9000

+0

看來,如果你有在你的應用程序的任何字符串描述字符串(如定位服務),它會拋出一個警告,爲每一個不是評論的字符串。 – karl

-1

我相信這會解決它。將android:contentDescription=」@string/description」添加到您的xml中。描述的目的是爲了訪問。這是不需要的,你的應用程序將在沒有它的情況下正常運行。但是,養成包括它的習慣是一種好習慣。

+0

謝謝你,在XML和其標籤應該我添加它? – HAL9000

+0

正在使用'strings.xml'的圖。所以你在哪裏聲明你的屬性。 –

+1

@Binghammer警告在'strings.xml'中,佈局文件中沒有警告/錯誤。有很多使用字符串的視圖,你是否說他們都需要一個內容描述屬性? –

0

確保你在strings.xml中有資源,然後你可以嘗試刷新。如果仍然有錯誤,請嘗試關閉項目,然後重新打開它。如果所有這些都不起作用,請嘗試清理該項目。

+1

-1,因爲OP沒有錯誤,這些都不過是傳統的故障排除步驟。 – HAL9000

-1

您可以輕鬆地禁用此皮棉警告。

右鍵單擊「問題」窗口中的警告,然後單擊「快速修復」。然後,您可以禁用該文件,項目或任何地方的檢查。

+1

禁用警告它永遠不是解決方案。我解釋一下:如果我想清除警告,那是因爲我關心警告。更好的解決辦法是簡單地閉上眼睛。 – HAL9000

1

此前夕,雖然它是舊的一個適當的解決方法是這樣的: [注意文件名是不準確在大多數情況下,只是一個指南]

1. In your fragment_main.xml (/ProjectName/res/layout/fragment_main.xml) 
change your view and add this: 
    <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    <!-- Add this one line below as "contentDescription" refers to this issue 
     of description not found warning by Lint --> 
    android:contentDescription="@string/description" 
    android:text="@string/hello_world" /> 

2. The @string references the strings in your strings.xml and the name 
    of the string itself is "description" 
    So in your ProjectName/res/values/strings.xml add: 

    <string name="description">Variables</string> 
相關問題