Code example for TableLayout

Methods: getChildAt

0
    String countryName = getCountryName(correctAnswer);
    ((Button) randomTableRow.getChildAt(column)).setText(countryName);
  } 
 
  private TableRow getTableRow(int row) {
    return (TableRow) buttonTableLayout.getChildAt(row);
  } 
 
  private String getCountryName(String name) {
    return name.substring(name.indexOf('-') + 1).replace('_', ' ');
  } 
 
  private void submitGuess(Button guessButton) {
    String guess = guessButton.getText().toString(); 
    String answer = getCountryName(correctAnswer); 
    ++totalGuesses; 
 
    if (guess.equals(answer)) { 
      ++correctAnswers; 
 
      answerTextView.setText(answer + "!");