1

我是android的新手,我被以下难题困住了。

我需要在 Android 中创建一个如下所示的表:

类别 | 商品名称 | 获得的分数 | 最大标记|


第 1 行信息


第 2 行信息


我面临的问题是这些行需要根据项目的数量动态创建。
我环顾四周,发现表格布局信息非常通用,或者没有显示如何创建动态表格。

PS我无法附上表格的确切图片,因为我没有足够的积分

4

1 回答 1

0

你创造了这个。首先创建一个表。现在您知道了要(动态)创建的行数。

    private TableLayout myTableLay;
    private TableRow demoTableRow[];
    private String cat[],itemName[],marks[],maxMarks[];    
    private int count;
        public void example()
    {
      myTableLay = new TableLayout(this);
      myTableLay.removeAllViews();
      myTableLay.refreshDrawableState();

     // i hope now you got count.
      demoTableRow = new TableRow[count];
      cat = new String[count];
      itemName= new String[count];
      marks= new String[count];
      maxMarks= new String[count];

     for(int i=0;i<count;i++)
      {
         // add all inforamation to your tablerow in such a maaner that you want to display on screen.


     myTableLay.addView(demoTableRow[i);
       }
 //hope it might helpful.
    }
于 2011-06-30T03:58:47.307 回答