The answer by Nunu is correct, but I would like to expand on it a little. The assumption is that loadingTask
is an AsyncTask
, thus when you call execute
the code within doInBackground
will execute asynchronously. The code where you create and populate the array will execute in parallel to your population of PostDetails
, which I assume is populated within the loadingTask
. Since the array loop will execute very quickly, it will have completed long before the network operation performed by loadingTask
. Thus your page is blank because you have looped through the array before PostDetails
has been populated.
The solution is just as Nunu suggests, which is to move the population of the imageUrls
array into the onPostExecute
method of your AsyncTask
. Also, any UI manipulation that uses this array should also be moved into onPostExecute
.