1

我正在按照 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
4

2 回答 2

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>
于 2013-02-24T08:35:38.610 回答
0

在Eclipse中:右键单击Package Explorer选项卡中的项目->对话框中的“属性”->左侧菜单中的“Java构建路径”->“源”选项卡

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


编辑

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

于 2012-09-06T20:55:50.737 回答