Android 运行应用程序的困难

Android 运行应用程序的困难,android,eclipse,Android,Eclipse,我正在制作一个简单的android应用程序,带有一个按钮和一个编辑文本 在eclipse中,我编写了以下activity_main.xml文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" androi

我正在制作一个简单的android应用程序,带有一个按钮和一个编辑文本

在eclipse中,我编写了以下activity_main.xml文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:orientation="horizontal"
    >

    <EditText android:id="@+id/edit_message"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:hint="@string/edit_message" />

    <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_send" />


</LinearLayout>

在string.xml文件中,我编写了以下内容

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">v1</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>

</resources>

v1
输入消息
发送
设置
主要活动
代码本身没有显示任何错误,但当我尝试运行代码时,它会抛出错误


我该怎么办?

抛出了什么类型的错误?我不确定,但是在这里

<Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_send" /> 


您不使用android:id。如果您没有按钮的
id
,则不能在java代码中使用它。

您需要为将在java代码中使用的按钮指定id

<Button 
    android:id="@id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_send" />


出现错误时,请学习阅读日志。没有这些信息,你就是瞎子,不知道你所面临问题的本质。你需要在这里发布日志,以便人们帮助你。你可以发布日志错误吗