Android ScrollView peut accueillir un seul enfant direct

J'ai un onclick auditeur dans la galerie qui doit effacer toutes les lignes à l'intérieur de la tableview, puis ajouter des lignes, des lignes à un tableview à l'intérieur d'un scrollview. Le fragment doit changer à chaque clic sur le bouton.

Cependant j'obtiens: java.lang.IllegalStateException: le ScrollView peut accueillir un seul enfant direct.

myactivity bouton de l'écouteur

            TrackerFragment tf = (TrackerFragment) getFragmentManager().findFragmentById(R.id.tracker1);
            tf = TrackerFragment.newInstance(listOfList.get(id).get(position));

            fragmentTransaction.add(R.id.tracker1, tf);
            fragmentTransaction.commit();
            t1 = true; //being used
            getFragmentManager().executePendingTransactions();

tracker fragment

public class TrackerFragment extends Fragment
{
private Dish dish;
public static TrackerFragment newInstance(Serializable dish) 
{
TrackerFragment tf = new TrackerFragment();
Bundle args = new Bundle();
args.putSerializable("dish", dish);
tf.setArguments(args);
return tf;
}
public static TrackerFragment newInstance(Bundle bundle)
{
Dish dish = (Dish) bundle.getSerializable("dish");
return newInstance(dish);
}
@Override
public void onCreate(Bundle myBundle)
{
super.onCreate(myBundle);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) 
{
View v = inflater.inflate(R.layout.tracker, container, false);
TableLayout tableLayout = (TableLayout) v.findViewById(R.id.tracker_layout);
tableLayout.removeAllViews();
if (dish != null)
{   
//display others
//display subsystem stuff
for (int i = 0; i < dish.getSubsystems().size(); i++)
{
TableRow tableRow = new TableRow(v.getContext());
tableRow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView tv = new TextView(v.getContext());
tv.setText(dish.getSubsystems().get(i).getConnFuncAddr());
tableRow.addView(tv);
tableLayout.addView(tableRow);
}
}
else
{
TableRow tableRow = new TableRow(v.getContext());
tableRow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView tv = new TextView(v.getContext());
tv.setText("Click on image to view more data");
tableRow.addView(tv);
tableLayout.addView(tableRow);
}
return v;
}
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="horizontal" 
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Trackers -->
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="300dp"
android:layout_weight="1"
android:orientation="vertical">
<fragment 
android:name="android.gallery.TrackerFragment"
android:id="@+id/tracker1"
android:layout_height="500dp"
android:layout_width="300dp"
android:layout_weight="1">
</fragment>
</LinearLayout>
<!-- Gallery -->
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="600dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="245dp">
<Gallery 
android:id="@+id/galleryid0"
android:layout_width="fill_parent" 
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="245dp">
<Gallery 
android:id="@+id/galleryid1"
android:layout_width="fill_parent" 
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="245dp">
<Gallery 
android:id="@+id/galleryid2"
android:layout_width="fill_parent" 
android:layout_height="match_parent"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

tracker.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent"
android:id="@+id/tracker_layout">
</TableLayout>
</ScrollView>

Personne ne sait quoi de mal? Je devine que je suis l'ajout d'une ligne de tableau à la scrollview et pas la tableview, cependant, je ne vois pas où je fais ce qui cloche dans mon code.

OriginalL'auteur Raptrex | 2011-06-30