2

I have a custom listview with two buttons and two textViews enclosed within linearlayout. I want to iterate through the listView without clicking the listView rows. When i do listView.getChildAt(position); position can be any integer from 0 onwards it gives null output, what is the other way to get views from listView. Please help.

Prakash Sejwani
  • 115
  • 4
  • 10

1 Answers1

1

There isn't really an interface exposed for getting the view objects from a ListView. These are constantly being switched out and stored for recycling as rows scroll in and out of the visible area.

However, you can do:

listView.getItemAtPosition(position);

to get the model (item) at a given position in the list. If you need to operate on information that the user changes in your list, then you would want to first save that information back to the underlying model individually when each component changes and then later aggregate over your underlying data objects to do your calculation.

Matthew
  • 44,826
  • 10
  • 98
  • 87
  • I do get model items with listView.getItemAtPosition(position); android.database.sqlite.SQLiteCursor@43e7b818, but i have a condt like in listview there is one more textView with counter from 0 onwards if that is more than 0 i want to pick that item from the model – Prakash Sejwani Apr 08 '11 at 19:33