Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all children (visible and invisible) from a ListView?

My problem is similar to ListView getChildAt returning null for visible children, but despite searching I cannot find a solution.

I have a ListView with a Scroll. The ListView has 10 items, 7 of which are visible and 3 are hidden by scroll. I also have an external method (out of adapter) that must get all of the children from this ListView (e.g. using getChildAt()).

I need all 10 of the items, but the last 3 are null objects. I've tried code like the following:

getListView().smoothScrollToPosition();

But this doesn't work.

I think that I don't need to post the rest of my code, as the description says everything?

like image 246
Vig Avatar asked Dec 19 '12 10:12

Vig


1 Answers

As you have already seen you can't get all the child row views from a ListView simply because a ListView holds only the views for the visible rows(plus some recycled rows but you can't reach those). The correct way to do what you want is to store whatever data in the adapter's data and retrieve it from there.

But the ListView doesn't keep the current values from RadioGroup in running time.

I've seen that you have some problems with this so I've adapted some old code to build a basic example, code that you can find here.

like image 56
user Avatar answered Sep 22 '22 17:09

user