1
현재 프로젝트의 일부 Google 코드를 수정하고 있습니다. 방금이 수업에 오류가 생기기 시작했습니다.이 수업을 전혀 변경하지 않았기 때문에 의문을 품고 있습니다.지정된 자녀가 이미 Google 알람 시계 코드에 상위 항목이 있습니다.
다음은 오류입니다 :
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.skipmorrow.powerclock/com.skipmorrow.powerclock.SetAlarm}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2304)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2354)
at android.app.ActivityThread.access$600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5191)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:3339)
at android.view.ViewGroup.addView(ViewGroup.java:3210)
at android.view.ViewGroup.addView(ViewGroup.java:3186)
at com.skipmorrow.powerclock.SetAlarm.onCreate(SetAlarm.java:134)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258)
그리고 여기에 코드입니다. 내가 말했듯이, 나는 그것에 변화를주지 않았으며, 프로젝트 요구 사항에 따라 변경하지 않아도된다. 필요가 없다면 나는 거기에 들어가서 싫어한다. 전체 프로젝트는 여기에 있습니다 : 내가 API 8에 대한
// Get the main ListView and remove it from the content view.
ListView lv = getListView();
content.removeView(lv);
// Create the new LinearLayout that will become the content view and
// make it vertical.
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
// Have the ListView expand to fill the screen minus the save/cancel
// buttons.
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
lp.weight = 1;
ll.addView(lv, lp); // error here. Line 134
로 변경해야 할 것입니다 있습니다. 이상하게도 구글 코드에는 그 단순한 것이있었습니다. 오 잘 ... 고마워! – MrGibbage