java - Android开发R无法解析为变量(找不到资源错误)

标签 java android resources r.java-file

昨天我正在开发我的 Android 应用程序,它运行良好。但今天当我打开它时,我收到错误 R cannot be resolved to a variable我不知道为什么会发生这种情况。在控制台中我收到此错误 [2014-03-29 11:04:59 - RockPaperScissors] C:\Users\hosfo_000\workspace2\RockPaperScissors\res\menu\main.xml:6: error: Error: No resource found that matches the given name (at 'title' with value '@string/action_settings'). 有谁知道可能导致此问题的原因是什么?我已经尝试清理该项目,但没有成功。

编辑

我的 main.XML 的第 6 行是 <item所以我添加了该项目的其余部分。我的整个 main.xml 都包含此项。

<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:title="@string/action_settings"
    app:showAsAction="never"/>

最佳答案

您确定字符串 action_settings 存在于 res/values/strings 中吗?

将其添加到 res/values/strings 文件

<resources>
<string name="action_settings">Action Settings</string>
<string name="app_name">The name of your app</string>
</resources>

关于java - Android开发R无法解析为变量(找不到资源错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22733474/

相关文章:

android - 背景图像未显示在手机上

java - java中如何将一个数组拆分为多个数组?

JavaFX 2 场景切换

java - Android:如何从字符串创建位图?

c# - 在 C# 中循环遍历不同语言/文化的嵌入式资源

android - "Social"Android 应用程序中的国际化 - 动态加载资源

java - 通过Junrar解压rar文件然后删除压缩包

javascript - 在 Selenium 中使用 javascript 设置字段值

android - 如何在 Delphi 中以编程方式在 android 设备上启用 wi-fi?

Android RxJava 2 JUnit 测试 - android.os.Looper 中的 getMainLooper 未模拟 RuntimeException