How to determine when a ListView will be populated

I need to manipulate the children of a ListView when this is done at boot time, but I cannot find a way to find out when this will happen. When I install the adapter of my ListView, the method returns immediately, but its population is treated as asynchronously. Is there a way to handle the event when the list is filled with views?

+6
source share
2 answers

You can do a periodic survey to find out if the list has been populated: write a while () loop to check once in a while. Or you can wait a fixed amount of time (for example, 30 ms) before performing the next operation. These are not recommended methods, but they should solve your problem.

+3
source

Use getChildCount() to retrieve the displayed views, and also use a counter to keep track of how many views have been loaded asynchronously. I think I understand your question correctly.

0
source

Source: https://habr.com/ru/post/926235/


All Articles