14

Is it possible to bind a TableLayout with a ArrayAdapter?

Ricardo Altamirano
  • 12,617
  • 20
  • 67
  • 104
Manish Khot
  • 2,957
  • 1
  • 25
  • 37

1 Answers1

27

There is no such API in the framework. You can do it manually by querying the adapter yourself. Something like this:

int count = adapter.getCount();
for (int i = 0; i < count; i++) {
    tableLayout.addView(createTableRow(adapter.getItem(i)); // or tableLayout.addView(adapter.getView(i, null, tableLayout));
}
Romain Guy
  • 95,351
  • 17
  • 214
  • 199
  • 3
    Thanks for your response. How do i ensure that the views are getting recycled as that of the convert View? – Manish Khot Feb 18 '11 at 09:43
  • 10
    You can't unless you are willing to reimplement a view recycler like ListView's, and trust me, it's a lot of work you don't want to do :p – Romain Guy Feb 18 '11 at 10:05