I am trying to use the following code to go through an ArrayList of
LinearLayout objects, add each one to a TableLayout, and finally add
that TableLayout to a ScrollView defined in the main.xml file.
ScrollView theScrollView = (ScrollView) findViewById
(R.id.scroll_view);
TableLayout theList = new TableLayout(this);
ArrayList<LinearLayout> theArray = Edit.getTheArray();
if (theArray.size() > 0) {
for (int i = 0; i < theArray.size(); i++) {
theList.addView(theArray.get(i));
}
theScrollView.addView(theList);
}
A second activity (Edit) is used to convert user input into a new
LinearLayout and put it in the ArrayList. The code works successfully
on the first item in the Array, however, after adding a second
LinearLayout to the ArrayList and returning to the main activity, I
get a force close and the following error:
java.lang.IllegalStateException: The specified child already has a
parent. You must call removeView() on the child's parent first.
I can't seem to figure out what is happening here. Is there another
method I should be using to get my desired results?
--
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