strings.xml中的“未找到消息描述”警告

时间:2013-12-09 15:15:51

标签: android xml eclipse

我收到了来自strings.xml的大量恼人的警告。在每个声明的左侧,我收到一条警告,上面写着“未找到消息说明”。我该如何解决?

5 个答案:

答案 0 :(得分:10)

我有同样的问题,因为我已经更新了SDK。我找到了解决这个问题的方法。只需在string.xml文件中的每个字符串前添加注释,这将解决警告。

以下示例:

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

答案 1 :(得分: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>

答案 2 :(得分:0)

确保您拥有strings.xml中的资源,然后您可以尝试刷新。如果仍有错误,请尝试关闭项目,然后重新打开它。如果一切都不起作用,请尝试清理项目。

答案 3 :(得分:-1)

我相信这会解决它。将android:contentDescription=”@string/description”添加到您的xml中。描述的目的是为了可访问性。它不是必需的,没有它你的应用程序将正常运行。但是,优良做法是养成包含它的习惯。

答案 4 :(得分:-1)

您可以轻松禁用此lint警告。

右键点击问题&#39;中的警告。窗口,然后点击快速修复&#39;。然后,您可以禁用对文件,项目或任何地方的检查。

相关问题