Get all TableRow's in a TableLayout

前端 未结 5 935
春和景丽
春和景丽 2021-02-01 16:10

I\'ve been looking for hours on how to get all TableRow\'s in a TableLayout. I already know how to add and delete rows dynamically, but I need to loop over all the rows and sele

5条回答
  •  长发绾君心
    2021-02-01 16:37

    if you have other type view

    TableLayout layout = (TableLayout) findViewById(R.id.IdTable);
    
    for (int i = 0; i < layout.getChildCount(); i++) {
        View child = layout.getChildAt(i);
    
        if (child instanceof TableRow) {
            TableRow row = (TableRow) child;
    
            for (int x = 0; x < row.getChildCount(); x++) {
                View view = row.getChildAt(x);
                view.setEnabled(false);
            }
        }
    }
    

提交回复
热议问题