0

番組の期間を表す、行の高さが可変のテーブルを描画することにより、ある種のテレビスケジュールを実行しようとしています。問題は、行の高さが影響を受けないことです。すべての行は、子アイテムの高さを持ちます。いくつかのアドバイス?

コード:

for(int i=0;(i+1)<DownloadInfo.nextTitle.size();i++){

  // Create row
  tableRw = new TableRow(currentContext);
  tableRw.setPadding(0, 0, 0, Math.round(5*dpScale+0.5f));
  nx_table.addView(tableRw);

  // Create and add time label
  tableTv = new TextView(currentContext);
  tableTv.setPadding(0, 0, Math.round(5*dpScale+0.5f), 0);
  tableTv.setText(outFormater.format(DownloadInfo.nextTime.get(i)));
  tableTv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
  tableRw.addView(tableTv);

  // Create and add title label
  tableTv = new TextView(currentContext);
  tableTv.setText(DownloadInfo.nextTitle.get(i));
  tableTv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));
  tableRw.addView(tableTv);

  // Modify row height
  long timeDifference = (DownloadInfo.nextTime.get(i+1).getTime()-DownloadInfo.nextTime.get(i).getTime())/200000;
  tableRw.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,tableRw.getChildAt(0).getHeight()+Math.round((timeDifference)*dpScale+0.5f)));
  Log.d("RPod_MainActivity","Height of row"+i+": "+tableRw.getChildAt(0).getHeight()+Math.round((timeDifference)*dpScale+0.5f));
}

Logcat の出力は次のとおりです。

06-21 23:02:12.675: DEBUG/RPod_MainActivity(27189): Height of row0: 032
06-21 23:02:12.679: DEBUG/RPod_MainActivity(27189): Height of row1: 029
06-21 23:02:12.679: DEBUG/RPod_MainActivity(27189): Height of row2: 043
06-21 23:02:12.683: DEBUG/RPod_MainActivity(27189): Height of row3: 038
06-21 23:02:12.687: DEBUG/RPod_MainActivity(27189): Height of row4: 025
06-21 23:02:12.691: DEBUG/RPod_MainActivity(27189): Height of row5: 022
06-21 23:02:12.691: DEBUG/RPod_MainActivity(27189): Height of row6: 044
06-21 23:02:12.695: DEBUG/RPod_MainActivity(27189): Height of row7: 034
06-21 23:02:12.695: DEBUG/RPod_MainActivity(27189): Height of row8: 040
06-21 23:02:12.699: DEBUG/RPod_MainActivity(27189): Height of row9: 013
06-21 23:02:12.699: DEBUG/RPod_MainActivity(27189): Height of row10: 067
06-21 23:02:12.703: DEBUG/RPod_MainActivity(27189): Height of row11: 059
06-21 23:02:12.703: DEBUG/RPod_MainActivity(27189): Height of row12: 05
06-21 23:02:12.707: DEBUG/RPod_MainActivity(27189): Height of row13: 017
06-21 23:02:12.707: DEBUG/RPod_MainActivity(27189): Height of row14: 032
06-21 23:02:12.710: DEBUG/RPod_MainActivity(27189): Height of row15: 04
06-21 23:02:12.714: DEBUG/RPod_MainActivity(27189): Height of row16: 02
06-21 23:02:12.714: DEBUG/RPod_MainActivity(27189): Height of row17: 040
06-21 23:02:12.718: DEBUG/RPod_MainActivity(27189): Height of row18: 049
06-21 23:02:12.718: DEBUG/RPod_MainActivity(27189): Height of row19: 052
06-21 23:02:12.722: DEBUG/RPod_MainActivity(27189): Height of row20: 04
06-21 23:02:12.722: DEBUG/RPod_MainActivity(27189): Height of row21: 041
06-21 23:02:12.722: DEBUG/RPod_MainActivity(27189): Height of row22: 032
06-21 23:02:12.726: DEBUG/RPod_MainActivity(27189): Height of row23: 016
06-21 23:02:12.730: DEBUG/RPod_MainActivity(27189): Height of row24: 07
06-21 23:02:12.730: DEBUG/RPod_MainActivity(27189): Height of row25: 026
06-21 23:02:12.730: DEBUG/RPod_MainActivity(27189): Height of row26: 050
06-21 23:02:12.734: DEBUG/RPod_MainActivity(27189): Height of row27: 032

だから、違いは目に見えるはずだと思います。しかし、そうではありません。

4

1 に答える 1

1

これを試してみましたnx_table.addView(tableRw, new LayoutParams(LayoutParams.MATCH_PARENT,tableRw.getChildAt(0).getHeight()+Math.round((timeDifference)*dpScale+0.5f))); か、または使用しましたか: ViewGroup.addView(view,w,h)

于 2012-06-21T21:28:23.810 に答える