动态添加许多表行而不冻结

时间:2014-08-17 23:17:13

标签: android dynamic view

我有一个空的TableLayout,当用户点击一个按钮时,我想用大约100行填充TableLayout。

以下是我动态添加行的代码:

public void addViewRow(TableLayout table, String... texts) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    TextView cell;

    TableRow row = (TableRow) inflater.inflate(R.layout.table_row, table, false);

    for(String text: texts) {
        cell = (TextView) inflater.inflate(R.layout.table_cell, row, false);
        cell.setText(text);
        row.addView(cell);
    }

    table.addView(row);
}

100行的问题是屏幕冻结了几秒钟...... 知道如何解决这个问题吗?

0 个答案:

没有答案
相关问题