I have an activity DisplayResults that gets started from my MainActivity
. In the DisplayResultsActivity
, it creates an object of a custom class ProductFinder in its onCreate()
function. In ProductFinder's constructor, there is a while
loop that takes about 10 seconds to execute.
My problem is that when I start DisplayResult
from MainActivity
, the whole screen goes black for the duration of the while loop, then finally the DisplayResults
activity shows on the screen with everything.
What I would like is to draw the DisplayResults
activity normally, then wait for the loop in the ProductFinder
class to finish what it's doing without having the entire UI freeze. Having a loading circle in the middle of DisplayResults
while the loop is running would be nice.
What is the proper method of doing this? I know that something needs to go in a thread, but I'm not sure which class to put the loading circle in and which code to put inside the thread.