環路錯誤我在我所獲取i
ID和ID下顯示所有j
值的分配。但我有一個問題:在i
第一值j
值正常,但在i
第二ID j
相同的價值即將到來,它顯示在第一ID;它沒有更新。在Java
的代碼片段是:
for (int i = 0; i <= assignment.getValue().size(); i++){
TableRow tr = new TableRow(this);
tr.setPadding(2, 2, 2, 2);
TableLayout.LayoutParams tableRowParams=
new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.FILL_PARENT);
int leftMargin=0;
int topMargin=2;
int rightMargin=0;
int bottomMargin=1;
tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
tr.setLayoutParams(tableRowParams);
value[i]= new TextView(this);
value[i].setText(assignment.getValue().get(i));
System.out.println(value[i].getText().toString());
value[i].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
tr.addView(value[i]);
for(int j= 0; j < assignment.getScore().size()/assignment.getValue().size(); j++){
scr[i]= new TextView(this);
scr[i].setText(categorylist.getScore().get(j));
System.out.println(scr[i].getText().toString());
scr[i].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
tr.addView(scr[i]);
} t1.addView(tr, tableRowParams);
請張貼*真正*代碼,而不是你的僞代碼修復。 –
不足以識別問題 –
您的'j'循環不會對'i'或任何派生自外部循環的內容執行操作......因此無論「i」如何都是相同的輸出。事實上,如果你將嵌套的'j'循環移出來以便'獨立',你會得到同樣的結果。 –