0

我是这个 android 编程的新手,不知道从哪里开始我的问题,也不知道我应该在这里发布什么。在这里,我的日志在 Eclipse 中显示为红色。当我启动应用程序并输入内容并单击发送时,应用程序将崩溃,并且我将在 Eclipse 中获得此日志。我正在学习本教程:开始另一个活动

希望有人可以帮助我

09-10 21:40:45.783: E/AndroidRuntime(25911): FATAL EXCEPTION: main
09-10 21:40:45.783: E/AndroidRuntime(25911): android.app.SuperNotCalledException: Activity {com.example.hello.world/com.example.hello.world.DisplayMessageActivity} did not call through to super.onCreate()
09-10 21:40:45.783: E/AndroidRuntime(25911):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2160)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at android.app.ActivityThread.access$600(ActivityThread.java:139)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at android.os.Looper.loop(Looper.java:154)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at android.app.ActivityThread.main(ActivityThread.java:4945)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at java.lang.reflect.Method.invokeNative(Native Method)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at java.lang.reflect.Method.invoke(Method.java:511)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-10 21:40:45.783: E/AndroidRuntime(25911):    at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

2

在您的onCreate方法中DisplayMessageActivity,将其称为第一行:

super.onCreate(savedInstanceState);

实际上,您的教程说明了这一点(尽管我添加了评论...):

public class DisplayMessageActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); // This is important!
        setContentView(R.layout.activity_display_message);
    }
}
于 2012-09-10T19:46:15.263 回答