Android的“构建简单用户界面”教程出错(Error in Android's “Building a Simple User Interface” tutorial)
所以我试图使用Eclipse跟随Android的“构建单一用户界面”教程,但是我遇到了两个错误,导致我的代码无法运行。
第一个错误是在res / menu / main.xml广告中说:
错误:错误:找不到与给定名称匹配的资源(在'title'处,值为'@ string / action_settings')。
给我这个错误的代码行是:
android:title="@string/action_settings"/>
我的第二个错误是在res / values / strings.xml中,并说:
错误:找到标记String期望项目的位置
为线
<String name="menu_settings">Settings</String>
整个“String.xml”文件如下:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">My First App</string> <string name="edit_message">Enter a message</string> <string name="button_send">Send</string> <String name="menu_settings">Settings</String> <String name ="title_activity_main">MainActivity</String> <String name ="action_settings">Settings</String> </resources>
虽然我在使用Java / Eclipse方面经验丰富,但我是Android和XML的新手,所以我完全不知道这些错误意味着什么。 您将提供的任何帮助将不胜感激!
So I'm attempting to follow along with Android's "Building a Single User Interface" tutorial using Eclipse, but I'm getting two errors that are keeping my code from running.
The first error is in res/menu/main.xml ad says:
error: Error: No resource found that matches the given name (at 'title' with value '@string/ action_settings').
The line of code that is giving me that error is:
android:title="@string/action_settings"/>
My second error is in res/values/strings.xml and says:
error: Found tag String where item is expected
for the line
<String name="menu_settings">Settings</String>
The entire "String.xml" file is as follows:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">My First App</string> <string name="edit_message">Enter a message</string> <string name="button_send">Send</string> <String name="menu_settings">Settings</String> <String name ="title_activity_main">MainActivity</String> <String name ="action_settings">Settings</String> </resources>
Though I'm experienced in using Java/Eclipse, I'm new to Android and XML, so I have absolutely no idea what these errors mean. Any help you could provide would be greatly appreciated!
原文:https://stackoverflow.com/questions/15648304
最满意答案
Jquery切换将为您完成,请参阅小提琴: https : //jsfiddle.net/c259LrpL/24/
$(".menu-item").click(function() { $(this).toggleClass("red"); });
CSS示例:
.menu-item { background-color: blue; color: white; } .menu-item.red { background-color: red; color: blue; }
Jquery toggle will do it for you, see fiddle: https://jsfiddle.net/c259LrpL/24/
$(".menu-item").click(function() { $(this).toggleClass("red"); });
CSS example:
.menu-item { background-color: blue; color: white; } .menu-item.red { background-color: red; color: blue; }