I am new to android. I have this in my code


CheckBox cb = new CheckBox(v.getContext());




Then a bit later on I have this



String[] Tempstr = str.split("#");
LinearLayout.removeAllViews();
for(int x = 0 ; x < Tempstr.length; x++){
       String[] TempTempstr = Tempstr[x].split("@");
cb.setText(TempTempstr[0] + ", " + TempTempstr[1] + ", " + TempTempstr[2]);
       LinearLayout.addView(cb);
}






When I test it using ecliipse I get




12-15 11:21:45.399: W/KeyCharacterMap(1136): No keyboard for id 0

12-15 11:21:45.399: W/KeyCharacterMap(1136): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

12-15 11:21:58.408: D/dalvikvm(1136): GC_CONCURRENT freed 156K, 50% free 2854K/5639K, external 505K/517K, paused 7ms+6ms

12-15 11:21:58.510: D/AndroidRuntime(1136): Shutting down VM

12-15 11:21:58.510: W/dalvikvm(1136): threadid=1: thread exiting with uncaught exception (group=0x40015560)

12-15 11:21:58.510: E/AndroidRuntime(1136): FATAL EXCEPTION: main

12-15 11:21:58.510: E/AndroidRuntime(1136): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.view.ViewGroup.addViewInner(ViewGroup.java:1976)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.view.ViewGroup.addView(ViewGroup.java:1871)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.view.ViewGroup.addView(ViewGroup.java:1828)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.view.ViewGroup.addView(ViewGroup.java:1808)

12-15 11:21:58.510: E/AndroidRuntime(1136): at pub.vacancies.PubVacancies$1.onClick(PubVacancies.java:70)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.view.View.performClick(View.java:2485)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.view.View$PerformClick.run(View.java:9080)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.os.Handler.handleCallback(Handler.java:587)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.os.Handler.dispatchMessage(Handler.java:92)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.os.Looper.loop(Looper.java:123)

12-15 11:21:58.510: E/AndroidRuntime(1136): at android.app.ActivityThread.main(ActivityThread.java:3683)

12-15 11:21:58.510: E/AndroidRuntime(1136): at java.lang.reflect.Method.invokeNative(Native Method)

12-15 11:21:58.510: E/AndroidRuntime(1136): at java.lang.reflect.Method.invoke(Method.java:507)

12-15 11:21:58.510: E/AndroidRuntime(1136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

12-15 11:21:58.510: E/AndroidRuntime(1136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

12-15 11:21:58.510: E/AndroidRuntime(1136): at dalvik.system.NativeStart.main(Native Method)







The problem is this line

LinearLayout.addView(cb);



Can someone tell me why please as I have removed all the views so I am stumped





Thanks

Pam

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to