Android Lint - 如何隐藏警告 'The resource Xxx appears to be unused'

标签 android resources android-lint

我想为某些特定资源禁用(新)Android Lint 警告“资源 Xxx 似乎未使用”。

对于其他 Lint 警告,我可以利用 Quick Assist,它显示了 3 个选项来禁用警告,其中一个是针对该特定文件的。

但是这个警告没有显示任何快速帮助,它在 Eclipse 中以通用黄色警告颜色出现在文件(定义资源的文件)的顶部。

我也尝试手动编辑 lint.xml 文件,如下所示:

<lint>
  <issue id="UnusedResources">
    <ignore path="res\layout\my_layout.xml" />
  </issue>
<lint>

但没有运气(我从 Android Lint 引用 here 中获取了 id)。

最佳答案

我今天遇到了这个问题,发现 Improving Your Code with lint页面非常有帮助。在“在 XML 中配置 lint 检查”部分中,它描述了如何忽略特定资源:

You can use the tools:ignore attribute to disable lint checking for specific sections of your XML files. In order for this attribute to be recognized by the lint tool, the following namespace value must be included in your XML file:

namespace xmlns:tools="http://schemas.android.com/tools"

然后您可以将 tools:ignore="UnusedResources" 添加到要忽略的资源中。

关于Android Lint - 如何隐藏警告 'The resource Xxx appears to be unused',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8587462/

相关文章:

android - 从 Pipeline 项目发布 Android Lint 结果

Android N 预览 dlopen() "has no section headers"错误

android - 使用 NDK 13 编译独立的二进制文件

android - 弹出后堆栈后,我的 fragment 没有被垃圾收集

java - 在 android 应用程序上存储 client_id 和 client_secret 的安全方法

ios - 自定义 iOS 框架中的资源

android - lint.xml 的上下文和检查配置文件

WPF 查找资源和内存泄漏

android - 找不到与给定名称 Xamarin Android 匹配的资源

android - 奇怪的 Lint 警告 - 在布局文件 : "" 中发现意外文本