Code example for TableRow

Methods: getChildCount

0
     */ 
    public void clear() { 
        runningScoresTable.removeAllViews();
        currentScoresTable.removeAllViews();
 
        runningScoresHeader = new TableRow(context);
        runningScoresTable.addView(runningScoresHeader);
 
        TableRow currentScoresHeader = new TableRow(context);
        TextView total = newTextView(-1);
        total.setText(pad("Σ"));
        currentScoresHeader.addView(total);
        currentScoresTable.addView(currentScoresHeader);
 
        runningScoresRows = new TableRow[model.playerCount()];
        playerTotals = new TextView[model.playerCount()];
 
        TableLayout.LayoutParams WRAP_PARAMS = new TableLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 
        for (int p = 0; p < model.playerCount(); p++) {
            TableRow playerRunningScores = new TableRow(context);
            runningScoresRows[p] = playerRunningScores;
            runningScoresTable.addView(playerRunningScores);
 
            TableRow currentScoresRow = new TableRow(context);
 
            TextView playerTotal = newTextView(p);
            playerTotal.setText(totalString(p));
            playerTotals[p] = playerTotal;
            playerTotal.setTypeface(null, Typeface.BOLD);
            currentScoresRow.addView(playerTotal);
 
            TextView playerName = newTextView(p);
            playerName.setGravity(Gravity.LEFT);
            playerName.setText(model.playerName(p));
            currentScoresRow.addView(playerName);
 
            currentScoresTable.addView(currentScoresRow, WRAP_PARAMS);
        } 
 
        runningScoresTable.setColumnStretchable(0, true);
    } 
 
    public void scoreChanged(int player, int round) {
        TextView roundScore = (TextView) runningScoresRows[player].getChildAt(round);
        roundScore.setText(getScore(player, round));
        playerTotals[player].setText(totalString(player));
    } 
 
    private String totalString(int player) {
        int total = model.playerTotal(player);
        return Integer.toString(total);
    } 
 
    private String getScore(int player, int round) {
        int score = model.playerScore(player, round);
        return score != 0 ? Integer.toString(score) : "";
    } 
 
    public void roundCountChanged() { 
        for (int r = runningScoresHeader.getChildCount(); r < model.roundCount(); r++) {
            TextView roundNumber = newTextView(-1);
            roundNumber.setText(pad(String.valueOf(r + 1)));
            runningScoresHeader.addView(roundNumber);
 
            for (int p = 0; p < model.playerCount(); p++) {