Good day,
I have a photo gallery that pulls from a json feed. The json gallery contains 600 photos, but I am pushing out 10 at a time, with the gallery reloading on the tenth feed.
Now I have two arrays.
PhotoList.length – carries a count of how many photos are in the feed
currentPhotoIndex. – It holds the index or place of the images.
The problem: currentPhotoIndex only shows 10 indexs no matter what. When I reload more data from the feed it overwrites the old data, keeping the index the same.
How to I add more index space to an array? I am thinking I can do an append to currentPhotoIndex, but how?
I need something like, currentPhotoIndex = currentPhotoIndex + 10; (this by the way gives me a current index of 20 instead of creating 10 empty spaces.)
Any help is appreciated.
Thanks
It sounds like you need to use an array list.
Here is a java code example to show the basics of how it works.
If it is not what you had in mind, try this:
Step1: Create an array of size 10, when it is full make a temporary array of array.size*2.
Step2: Now add the contents of the first array to the temp array.
Step3: Re-initialize the array with a new size (temp array size).
Step4: Now add the contents of the temp array to the resized array.
Step5: Repeat from step 1 as many times as neaded
Here is an example in java: