Android First App教程无效

时间:2012-09-06 20:44:39

标签: android

我正在关注Android开发人员教程来构建第一个应用程序。我正是一步一步地完成了它所说的并完成了这个页面:  https://developer.android.com/training/basics/firstapp/starting-activity.html

这里我收到许多与Java相关的错误:

Description                               Resource             Path                             Location    Type
View cannot be resolved to a type   MainActivity.java   /MyFirstApp/src/com/example/myfirstapp  line 24 Java Problem
Intent cannot be resolved to a type MainActivity.java   /MyFirstApp/src/com/example/myfirstapp  line 25 Java Problem
Intent cannot be resolved to a type DisplayMessageActivity.java /MyFirstApp/src/com/example/myfirstapp  line 16 Java Problem
TextView cannot be resolved to a type   DisplayMessageActivity.java /MyFirstApp/src/com/example/myfirstapp  line 20 Java Problem
TextView cannot be resolved to a type   DisplayMessageActivity.java /MyFirstApp/src/com/example/myfirstapp  line 20 Java Problem
Intent cannot be resolved to a type MainActivity.java   /MyFirstApp/src/com/example/myfirstapp  line 25 Java Problem
EditText cannot be resolved to a type   MainActivity.java   /MyFirstApp/src/com/example/myfirstapp  line 26 Java Problem
EditText cannot be resolved to a type   MainActivity.java   /MyFirstApp/src/com/example/myfirstapp  line 26 Java Problem
edit_message cannot be resolved or is not a field   MainActivity.java   /MyFirstApp/src/com/example/myfirstapp  line 26 Java Problem

请帮忙吗?

编辑: @pawalzieba好的,现在我只得到这3个错误:

Description Resource    Path    Location    Type
edit_message cannot be resolved or is not a field   MainActivity.java   /MyFirstApp/src/com/example/myfirstapp  line 29 Java Problem
error: Error: No resource found that matches the given name (at 'hint' with value '@string/edit_message').  activity_main.xml   /MyFirstApp/res/layout  line 6  Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '@string/button_send').   activity_main.xml   /MyFirstApp/res/layout  line 11 Android AAPT Problem

2 个答案:

答案 0 :(得分:3)

error: Error: No resource found that matches the given name (at 'hint' with value '@string/edit_message').  activity_main.xml   /MyFirstApp/res/layout  line 6  Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '@string/button_send').   activity_main.xml   /MyFirstApp/res/layout  line 11 Android AAPT Problem

尝试添加到strings.xml:

<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>

答案 1 :(得分:0)

在Eclipse中: 右键单击Package Explorer选项卡中的项目 - &gt;对话框中的“属性” - &gt;左侧菜单中的“Java Build Path” - &gt; “来源”标签

您可以在此处更改源文件夹。将其设置为指向项目中的src文件夹。


修改

缺少java文件中的导入。在Eclipse中按下此快捷键 Ctrl + Shift + O 以组织导入。