默认的eclips的android新活动崩溃了

时间:2014-03-29 17:30:16

标签: android eclipse

我正在通过android教程学习。我对new activity课程有疑问。如果我允许应用调用PlaceholderFragment(我还不知道它做了什么)应用程序崩溃了。如果我不是一切都按预期工作。这是由eclipse生成的PlaceholderFragment部分

public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_display_message,
                container, false);
        return rootView;
    }
}

我使用eclipse编译代码,并在Nexus 7设备(最新版本)上运行。最小的Android版本是2.2.3,当前的版本是最新的。

这是我做过的吗?我的设备有什么用?我的日食设置有哪些东西?

修改

03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.os.Handler.dispatchMessage(Handler.java:102)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.os.Looper.loop(Looper.java:136)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.ActivityThread.main(ActivityThread.java:5017)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at java.lang.reflect.Method.invokeNative(Native Method)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at java.lang.reflect.Method.invoke(Method.java:515)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at dalvik.system.NativeStart.main(Native Method)
03-29 20:41:57.934: E/AndroidRuntime(26725): Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f05003c (com.example.dungeonworlddruid:id/container) for fragment PlaceholderFragment{41fcb9d0 #0 id=0x7f05003c}
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:930)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.Activity.performStart(Activity.java:5241)
03-29 20:41:57.934: E/AndroidRuntime(26725):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
03-29 20:41:57.934: E/AndroidRuntime(26725):    ... 11 more
03-29 20:41:59.275: I/Process(26725): Sending signal. PID: 26725 SIG: 9

1 个答案:

答案 0 :(得分:0)

  

引起:java.lang.IllegalArgumentException:找不到id的视图   片段的0x7f05003c(com.example.dungeonworlddruid:id / container)   PlaceholderFragment {41fcb9d0#0 id = 0x7f05003c}

ViewGroup

中没有container代码为activity_main.xml的{​​{1}}

通常是FrameLayout。您可以在容器中添加或替换片段。

但是如果你对片段摆脱与片段相关的所有代码不感兴趣。

Adt的这次更新给开发人员带来了很多困惑。 eclipse中不需要更改设置,它与eclipse无关