我有扩展 FragmentActivity 的 Mainactivity ,我正在使用布局中加载片段
LinearLayout formLayout = (LinearLayout)findViewById(R.id.mainLayout);
formLayout.removeAllViews();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Search fragment = new Search(maincontrolActivity.this);
fragmentTransaction.add(R.id.mainLayout,fragment , "MY_FRAG");
fragmentTransaction.commit();
在 PatientSearch 我通过使用调用 apoointementsearch (另一个片段)
startActivity(new Intent(Search.this.getActivity(), AppointementSearch.class).putExtra("Position",0));
but it crashs giving this log ,I am sure that I put them in the AndroidManifest
07-18 17:13:15.780: E/AndroidRuntime(3579): FATAL EXCEPTION: main
07-18 17:13:15.780: E/AndroidRuntime(3579): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appnetics/com.appnetics.AppointementSearch}: java.lang.InstantiationException: com.appnetics.AppointementSearch
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1739)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.app.ActivityThread.access$500(ActivityThread.java:122)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.os.Looper.loop(Looper.java:132)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.app.ActivityThread.main(ActivityThread.java:4123)
07-18 17:13:15.780: E/AndroidRuntime(3579): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 17:13:15.780: E/AndroidRuntime(3579): at java.lang.reflect.Method.invoke(Method.java:491)
07-18 17:13:15.780: E/AndroidRuntime(3579): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
07-18 17:13:15.780: E/AndroidRuntime(3579): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
07-18 17:13:15.780: E/AndroidRuntime(3579): at dalvik.system.NativeStart.main(Native Method)
07-18 17:13:15.780: E/AndroidRuntime(3579): Caused by: java.lang.InstantiationException: com.appnetics.AppointementSearch
07-18 17:13:15.780: E/AndroidRuntime(3579): at java.lang.Class.newInstanceImpl(Native Method)
07-18 17:13:15.780: E/AndroidRuntime(3579): at java.lang.Class.newInstance(Class.java:1301)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.app.Instrumentation.newActivity(Instrumentation.java:1025)
07-18 17:13:15.780: E/AndroidRuntime(3579): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1730)
07-18 17:13:15.780: E/AndroidRuntime(3579): ... 11 more