【发布时间】:2013-12-09 15:15:50
【问题描述】:
我从我的 strings.xml 收到大量烦人的警告。在每个声明的左侧,我都会收到一条警告,上面写着“找不到消息描述。”。我该如何解决?
【问题讨论】:
我从我的 strings.xml 收到大量烦人的警告。在每个声明的左侧,我都会收到一条警告,上面写着“找不到消息描述。”。我该如何解决?
【问题讨论】:
我有同样的问题,因为我已经更新了 SDK。我找到了解决这个问题的方法。只需在您的 string.xml 文件中的每个字符串之前添加注释,这将解决警告。
示例如下:
<!-- Description here -->
<string name="app_name">Test App</string>
【讨论】:
这个前夜的一个适当的解决方法是: [注意文件名在大多数情况下并不准确,仅供参考]
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>
【讨论】:
确保您在 strings.xml 中有资源,然后您可以尝试刷新。如果仍然有错误,请尝试关闭项目,然后重新打开它。如果所有这些都不起作用,请尝试清理项目。
【讨论】:
我相信这会解决它。将android:contentDescription=”@string/description” 添加到您的 xml。描述的目的是为了便于访问。它不是必需的,没有它您的应用程序将正常运行。但是,养成包含它的习惯是一种好习惯。
【讨论】:
strings.xml的视图。所以你在哪里声明你的属性。
您可以轻松禁用此 lint 警告。
右键单击“问题”窗口中的警告,然后单击“快速修复”。然后您可以禁用对文件、项目或任何地方的检查。
【讨论】: