Я пытаюсь напечатать значение TextViews, которые находятся внутри TableRows, используя TableLayout#getChildAt(i).getChildAt(j)
.Невозможно выбрать детей (textview) tableRow программно
Когда я пытаюсь зарегистрировать его, используя приведенное выше, logcat жалуется, говоря, что это объект View и что у него нет метода, который я пытаюсь использовать (getText()
).
Единственные виды в TableRows - это TextViews.
// List<TextView> textViewBoxes...
private void createViews() {
...
tblLayout = new TableLayout(this);
tblRow01 = new TableRow(this);
...
for (int i = 0; i < 99; i++) {
TextView text = new TextView(this);
text.setText("Player " + i);
textViewBoxes.add(text);
}
tblRow01.addView(textViewBoxes.get(0));
...
tblLayout.addView(tblRow01);
...
// Print the contents of the first row's first TextView
Log.d(TAG, ("row1_tv1: " +
tblLayout.getChildAt(0).getChildAt(0).getText().toString));
...
}