Thanks, that little change to the manifest did exactly what I wanted. As for the error, I don't know why but now it's a RemoteException, and it happens the second time I push a button and try to add a view. That is, if I start out with the 2D view, I can change to 3D but then I try changing back to 2D and it crashes when trying to add the 2D view even though I remove it when I press the 3D button. Could it be that removeView doesn't actually remove the view at all, but just hides it? Either way, what I want is to only have one view attached to my main view with the radio buttons, at all times.
Here is the logcat output: 03-09 16:57:30.061 D/AndroidRuntime( 958): 03-09 16:57:30.061 D/AndroidRuntime( 958): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 03-09 16:57:30.088 D/AndroidRuntime( 958): CheckJNI is ON 03-09 16:57:30.638 D/AndroidRuntime( 958): --- registering native functions --- 03-09 16:57:32.418 D/PackageParser( 564): Scanning package: /data/app/ vmdl35068 .tmp 03-09 16:57:32.657 I/jdwp ( 958): received file descriptor 27 from ADB 03-09 16:57:32.710 I/PackageManager( 564): /data/app/vmdl35068.tmp changed; unp acking 03-09 16:57:32.737 D/installd( 543): DexInv: --- BEGIN '/data/app/ vmdl35068.tmp ' --- 03-09 16:57:33.288 D/dalvikvm( 965): DexOpt: load 124ms, verify 49ms, opt 2ms 03-09 16:57:33.338 D/installd( 543): DexInv: --- END '/data/app/ vmdl35068.tmp' (success) --- 03-09 16:57:33.537 I/installd( 543): move /data/dalvik-cache/ d...@app@vmdl35068 ....@classes.dex -> /data/dalvik-cache/ d...@app@com.test....@classes.dex 03-09 16:57:33.577 D/PackageManager( 564): New package installed in / data/app/c om.test.apk 03-09 16:57:33.877 D/AndroidRuntime( 958): Shutting down VM 03-09 16:57:33.887 D/dalvikvm( 958): DestroyJavaVM waiting for non- daemon threa ds to exit 03-09 16:57:33.928 D/dalvikvm( 958): DestroyJavaVM shutting VM down 03-09 16:57:33.937 D/dalvikvm( 958): HeapWorker thread shutting down 03-09 16:57:33.937 D/dalvikvm( 958): HeapWorker thread has shut down 03-09 16:57:33.937 D/jdwp ( 958): JDWP shutting down net... 03-09 16:57:33.937 D/jdwp ( 958): +++ peer disconnected 03-09 16:57:33.937 I/dalvikvm( 958): Debugger has detached; object registry had 1 entries 03-09 16:57:33.957 D/dalvikvm( 958): VM cleaning up 03-09 16:57:34.058 D/dalvikvm( 958): LinearAlloc 0x0 used 629572 of 4194304 (15 %) 03-09 16:57:34.558 D/dalvikvm( 564): GC freed 5649 objects / 328304 bytes in 39 9ms 03-09 16:57:34.588 D/HomeLoaders( 608): application intent received: android.in tent.action.PACKAGE_ADDED, replacing=false 03-09 16:57:34.588 D/HomeLoaders( 608): --> package:com.test 03-09 16:57:34.588 D/HomeLoaders( 608): --> add package 03-09 16:57:34.748 W/ResourceType( 564): No package identifier when getting val ue for resource number 0x7f060000 03-09 16:57:34.777 W/ResourceType( 564): No package identifier when getting val ue for resource number 0x7f060001 03-09 16:57:35.977 D/AndroidRuntime( 970): 03-09 16:57:35.977 D/AndroidRuntime( 970): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 03-09 16:57:35.987 D/AndroidRuntime( 970): CheckJNI is ON 03-09 16:57:36.710 D/AndroidRuntime( 970): --- registering native functions --- 03-09 16:57:38.398 I/ActivityManager( 564): Starting activity: Intent { flags=0 x10000000 comp={com.test/com.test.App} } 03-09 16:57:38.568 D/AndroidRuntime( 970): Shutting down VM 03-09 16:57:38.579 D/dalvikvm( 970): DestroyJavaVM waiting for non- daemon threa ds to exit 03-09 16:57:38.607 D/dalvikvm( 970): DestroyJavaVM shutting VM down 03-09 16:57:38.607 D/dalvikvm( 970): HeapWorker thread shutting down 03-09 16:57:38.617 D/dalvikvm( 970): HeapWorker thread has shut down 03-09 16:57:38.627 D/jdwp ( 970): JDWP shutting down net... 03-09 16:57:38.667 D/dalvikvm( 970): VM cleaning up 03-09 16:57:38.739 I/ActivityManager( 564): Start proc com.test for activity co m.test/.App: pid=977 uid=10020 gids={} 03-09 16:57:38.918 D/dalvikvm( 970): LinearAlloc 0x0 used 637060 of 4194304 (15 %) 03-09 16:57:40.207 I/ActivityManager( 564): Displayed activity com.test/.App: 1 785 ms 03-09 16:57:40.417 I/jdwp ( 977): received file descriptor 30 from ADB 03-09 16:57:40.598 W/System.err( 977): Can't dispatch DDM chunk 46454154: no ha ndler defined 03-09 16:57:40.598 W/System.err( 977): Can't dispatch DDM chunk 4d505251: no ha ndler defined 03-09 16:57:43.149 D/AndroidRuntime( 977): Shutting down VM 03-09 16:57:43.161 W/dalvikvm( 977): threadid=3: thread exiting with uncaught e xception (group=0x4000fe70) 03-09 16:57:43.170 E/AndroidRuntime( 977): Uncaught handler: thread main exitin g due to uncaught exception 03-09 16:57:43.217 E/AndroidRuntime( 977): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.addVie wInner(ViewGroup.java:1816) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.addVie w(ViewGroup.java:1711) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.addVie w(ViewGroup.java:1668) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.addVie w(ViewGroup.java:1648) 03-09 16:57:43.217 E/AndroidRuntime( 977): at com.test.App $1.onCheckedChang ed(App.java:31) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.RadioGroup.set CheckedId(RadioGroup.java:172) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.RadioGroup.acc ess$600(RadioGroup.java:52) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.RadioGroup$Che ckedStateTracker.onCheckedChanged(RadioGroup.java:342) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.CompoundButton .setChecked(CompoundButton.java:125) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.CompoundButton .toggle(CompoundButton.java:85) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.RadioButton.to ggle(RadioButton.java:69) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.CompoundButton .performClick(CompoundButton.java:97) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.View.onTouchEven t(View.java:3828) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.widget.TextView.onTou chEvent(TextView.java:6291) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.View.dispatchTou chEvent(View.java:3368) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.dispat chTouchEvent(ViewGroup.java:863) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.dispat chTouchEvent(ViewGroup.java:863) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.dispat chTouchEvent(ViewGroup.java:863) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.dispat chTouchEvent(ViewGroup.java:863) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewGroup.dispat chTouchEvent(ViewGroup.java:863) 03-09 16:57:43.217 E/AndroidRuntime( 977): at com.android.internal.policy.i mpl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java: 1707) 03-09 16:57:43.217 E/AndroidRuntime( 977): at com.android.internal.policy.i mpl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1197) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.app.Activity.dispatch TouchEvent(Activity.java:1993) 03-09 16:57:43.217 E/AndroidRuntime( 977): at com.android.internal.policy.i mpl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1691) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.view.ViewRoot.handleM essage(ViewRoot.java:1525) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.os.Handler.dispatchMe ssage(Handler.java:99) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.os.Looper.loop(Looper .java:123) 03-09 16:57:43.217 E/AndroidRuntime( 977): at android.app.ActivityThread.ma in(ActivityThread.java:3948) 03-09 16:57:43.217 E/AndroidRuntime( 977): at java.lang.reflect.Method.invo keNative(Native Method) 03-09 16:57:43.217 E/AndroidRuntime( 977): at java.lang.reflect.Method.invo ke(Method.java:521) 03-09 16:57:43.217 E/AndroidRuntime( 977): at com.android.internal.os.Zygot eInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 03-09 16:57:43.217 E/AndroidRuntime( 977): at com.android.internal.os.Zygot eInit.main(ZygoteInit.java:540) 03-09 16:57:43.217 E/AndroidRuntime( 977): at dalvik.system.NativeStart.mai n(Native Method) 03-09 16:57:43.278 I/Process ( 564): Sending signal. PID: 977 SIG: 3 03-09 16:57:43.278 I/dalvikvm( 977): threadid=7: reacting to signal 3 03-09 16:57:43.377 I/dalvikvm( 977): Wrote stack trace to '/data/anr/ traces.txt ' 03-09 16:57:44.808 I/Process ( 977): Sending signal. PID: 977 SIG: 9 03-09 16:57:44.847 I/ActivityManager( 564): Process com.test (pid 977) has died . 03-09 16:57:44.897 I/WindowManager( 564): WIN DEATH: Window{436e1840 com.test/c om.test.App paused=false} 03-09 16:57:45.247 W/InputManagerService( 564): Got RemoteException sending set Active(false) notification to pid 977 uid 10020 And the entire Java class is here: package com.test; import com.test.R; import android.app.Activity; import android.os.Bundle; import android.widget.RadioGroup; import android.widget.RelativeLayout; public class App extends Activity { RelativeLayout main; _2DView _2D; _3DView _3D; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); if (savedInstanceState == null) { _2D = new _2DView(this); _3D = new _3DView(this); main = (RelativeLayout) findViewById(R.id.window); main.addView(_2D); RadioGroup.OnCheckedChangeListener buttonListener = new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == R.id._2D) { main.removeView(findViewById(R.id._3D)); main.addView(_2D); } else if (checkedId == R.id._3D) { main.removeView(findViewById(R.id._2D)); main.addView(_3D); } } }; RadioGroup dimensions = (RadioGroup) findViewById(R.id.dimensions); dimensions.setOnCheckedChangeListener(buttonListener); } } } I couldn't find the /data/anr/traces.txt file anywhere though so I haven't included that. I see the problem in the logcat output though, the exception being that the child already has a parent, but since I do call removeView on main BEFORE adding another view, I don't see how this could be happening. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en