Print out ArrayList content in Android TableLayout

后端 未结 3 819
一生所求
一生所求 2020-12-30 18:20

I have this ArrayList:

 ArrayList debtList = datasource.debtList;
 ArrayList feeList = datasource.feeList;

How

3条回答
  •  忘掉有多难
    2020-12-30 18:49

    Assuming the number of entries in the ArrayLists are equal to the number of cells in the TableLayout, you can try something like this:

    int index = 0;
    TableLayout tableLayout = findViewById(R.id.table_layout);
    
    for(int n = 0, s = tableLayout.getChildCount(); n < s; ++n) {
        double debt = debtList.get(index);
        double fee = feeList.get(index);
    
        TableRow row = (TableRow) tableLayout.getChildAt(n);
        TextView cell = (TextView) row.findViewById(R.id.textview_cell);
    
        name.setText("debt = " + debt + ", fee = " + fee);
        index++;
    }
    

提交回复
热议问题