在Linearlayout中dynamic添加视图的问题

我想在LinearLayout添加多个视图。 这里是我用于添加多个视图到LinearLayout

Java代码:

 LinearLayout seriesMainListItemView = (LinearLayout) findViewById(R.id.SeriesMainListItemView); LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i=0; i<scheduleArr.length; i++) { View inflatedView = mInflater.inflate(R.layout.scheduleitem, null); TextView inflatertext1 = (TextView) inflatedView.findViewById(R.id.text1); TextView inflatertext2 = (TextView) inflatedView.findViewById(R.id.text2); inflatertext1.setText(scheduleArr[i][0]); inflatertext2.setText(scheduleArr[i][1]); Log.i("data",i + " " + scheduleArr[i][0] + "/" + scheduleArr[i][1]); seriesMainListItemView.addView(inflatedView); } 

这里是我想多次添加的View xml。

这里是我想要添加它的LinearLayout。

 <TableLayout android:layout_gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="1dip" android:paddingRight="1dip" > <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/imgSeriesMainScheduleImg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/scheduleheader"/> <LinearLayout android:id="@+id/SeriesMainListItemView" android:layout_width="fill_parent" android:layout_height="fill_parent"> </LinearLayout> </TableRow> .............. </TableLayout> 

但是LinearLayout中只添加了单个视图,尽pipe数组的长度是3.我的代码中有什么问题?

Solutions Collecting From Web of "在Linearlayout中dynamic添加视图的问题"