public void setRowsColumns(final String[] rows, final String[] cols) {

        final int addCells = 3;
        this.rows = rows;
        this.cols = cols;

        //initialize the data fields
        matrixGrid.setRowCount(rows.length + addCells);
        matrixGrid.setColumnCount(cols.length + addCells);
        this.data = new boolean[rows.length][cols.length];
        this.cbData = new CheckBox[rows.length][cols.length];
        this.cbRowAll = new CheckBox[rows.length];
        this.cbColAll = new CheckBox[cols.length];
        this.cbAllAll = null;
        this.cntRow = new int[rows.length];
        this.cntCol = new int[cols.length];
        this.cntAll = 0;

        //initialize the matrix view
        matrixGrid.removeAllViews();
        //top row: column labels
        this.addTextView("");
        this.addIconView(R.drawable.ic_menu_selectall);
        this.addVerticalSeparatorView();
        for (String c : cols) {
            this.addTextView(c);
        }
        //second row: selects for whole cols
        this.addIconView(R.drawable.ic_menu_selectall);
        this.cbAllAll = this.addCheckbox();
        this.cbAllAll.setOnCheckedChangeListener((v, ch) -> changeDataInternal(changer -> executeFor(-1, -1, (r, c) -> changer.call(r, c, ch))));
        this.addVerticalSeparatorView();
        for (int c = 0; c < cols.length; c++) {
            final int fC = c;
            this.cbColAll[c] = this.addCheckbox();
            this.cbColAll[c].setOnCheckedChangeListener((v, ch) -> changeDataInternal(changer -> executeFor(-1, fC, (rr, cc) -> changer.call(rr, fC, ch))));
        }
        //third row: separators
        for (int c = 0; c < cols.length + addCells; c++) {
            this.addHorizontalSeparatorView();
        }

        //fourth and more rows: data rows
        for (int r = 0; r < rows.length; r++) {
            final int fR = r;
            this.addTextView(rows[r]);
            this.cbRowAll[r] = this.addCheckbox();
            this.cbRowAll[r].setOnCheckedChangeListener((v, ch) -> changeDataInternal(changer -> executeFor(fR, -1, (rr, cc) -> changer.call(fR, cc, ch))));
            this.addVerticalSeparatorView();
            for (int c = 0; c < cols.length; c++) {
                final int fC = c;
                this.cbData[r][c] = this.addCheckbox();
                this.cbData[r][c].setOnCheckedChangeListener((v, ch) -> changeDataInternal(changer -> changer.call(fR, fC, ch)));
            }
        }
    }
(re-)initializes the matrix with given data. Matrix data is deleted in the process
main/src/main/java/cgeo/geocaching/ui/CheckboxMatrixView.java