我有三个彼此具有相同数量元素的列表,我想将所有列表的第一个元素放在一个表格中,然后将所有列表的第二个元素放在另一个表格中,这些列表是:
competitoinsIDs = new LinkedList<String>();
marks = new LinkedList<String>();
numOfQuestions = new LinkedList<String>();
所以我使用这个功能:
private void addTextViews() {
// TODO Auto-generated method stub
TableLayout tbl=(TableLayout) findViewById(R.id.tlMarksTable);
for(int ctr=0;ctr<marks.size();ctr++)
{
//Creating new tablerows and textviews
TableRow row=new TableRow(this);
TextView txt1=new TextView(this);
TextView txt2=new TextView(this);
TextView txt3=new TextView(this);
//setting the text
txt1.setText(competitoinsIDs.get(ctr));
txt2.setText(marks.get(ctr));
txt3.setText(numOfQuestions.get(ctr));
//the textviews have to be added to the row created
row.addView(txt1);
row.addView(txt2);
row.addView(txt3);
tbl.addView(row);
}
}
这是布局xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout
android:id="@+id/tlMarksTable"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:weightSum="2" >
<TextView
android:id="@+id/tvMarksCompetitionID"
android:layout_weight="1"
android:text="Competition"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvMarksMarks"
android:layout_weight="1"
android:text="Marks"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvMarksQuestionsNum"
android:layout_weight="1"
android:text="Questions"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
</TableLayout>
</FrameLayout>
请问我做错了什么?