我不知道发生了什么事,这让我感到害怕。
该项目似乎与我的资源脱离了某种程度。如果我将资源的ID(R.id.myId
更改为R.id.myId2
),项目将继续运行并正常运行,就像R.id.myId
仍然存在一样。如果我创建一个新字符串(R.string.newStr
),那么我的java代码并不知道它。它会抱怨资源不存在。
这开始时我在做什么?我正在为常见问题解答添加数组资源。我创建了一个新文件my_arrays.xml
,如下所示。我放了几个虚拟条目并运行它以确保它有效。它做了。此时,我的xml看起来如下(我已经重新创建了它)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="faq_questions_array">
<item>What\'s the news?</item>
<item>Is this good?</item>
</string-array>
<string-array name="faq_answers_array">
<item>All news is news?</item>
<item>The best ever</item>
</string-array>
</resources>
所以我把真正的常见问题解答放在了。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="faq_questions_array">
<item>What can this app do?</item>
<item>How do I add a course?</item>
<item>Can I edit or remove a course?</item>
<item>Can I edit/remove/view details of a grade?</item>
<item>How do I set the current semester?</item>
<item>How do I account for GPA from previous semesters? Do I have to manually recreate all grades from every course ever? </item>
<item>Why is a lot of my text red?</item>
<item>I found a bug. What should I do?</item>
<item>Do you have any sagely advice for my academic career?</item>
<item>What is something I should try?</item>
</string-array>
<string-array name="faq_answers_array">
<item>It can track your grades in your classes so that you stay organized and aware in face of slipping scholarships</item>
<item>There\'s a button. Main screen.</item>
<item>Well, you probably could if you pressed the menu button while on the course\'s screen.</item>
<item>Yup. When looking at your grade category (e.g., "Quizzes") tap the grade you want to mess with</item>
<item>The semester defaults based on the time of year it is and/or isn\'t. You can change it in the settings menu from the home screen.</item>
<item>Hilariously, yes! Seriously, no. Set your old credit and GPA in the Settings screen.</item>
<item>Because you're not studying enough.</item>
<item>It might be carrying diseases. Best kill it. Or email it to me at NSouthProductions@yahoo.com and I\'ll kill it for you.</item>
<item>Stay on top of your schoolwork. Know when things are due and how much time you'll need to prepare. Go with your gut on a tricky question, but analyze it and follow what's logical. But then remember your gut feeling and let your mind challenge it. Let your gut and mind duke it out and go with either.</item>
<item>Corn on pizza. They do it in Europe and it is delicious. Add broccoli for real yums. </item>
</string-array>
</resources>
我运行了我的应用程序并得到了......这个。它仍在使用旧字符串,即使它们不再存在于我的xml中。
现在我发现我的资源似乎完全脱离了。我在项目中搜索了这些旧字符串,但找不到它们。我重新启动了Eclipse,我的计算机,genymotion模拟器(并重新安装了它)。无论XML文件的内容如何,项目都会在我完成常见问题解答之前继续运行,就像资源完全正确一样。
帮助。
答案 0 :(得分:1)
确保您的xml文件没有任何错误,然后执行此操作:
项目 - &gt;干净 - &gt;清理所有项目
和:
项目 - &gt;自动构建
祝你好运答案 1 :(得分:0)
我之前遇到过这个。您需要清理项目并进行重建。
在Eclipse的菜单栏中,找到“Project”,然后单击“Clean ...”,“Clean all projects”,“OK”。
答案 2 :(得分:0)