Android CustomHow to get Child Views from Custom ListView enclosed within linearlayout without clicking listview
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开发者_JS百科 get views from listView. Please help.
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.
精彩评论