My app has a basic Google Maps activity, and on the map there is 4 markers which display some text. These markers are displayed on the map using a HashMap.
This is some of the code at the moment -
Double waterPrice = 1.38;
Double foodPrice = 1.23;
mMyMarkersArray.add(new MyMarkers("Tesco", "Tesco", Double.parseDouble("1.1111"), Double.parseDouble("-1.1111"), "Water: €" + waterPrice , "Food: €" + foodPrice , "Address: London"));
mMyMarkersArray.add(new MyMarkers("Sainsburys", "Sainsburys", Double.parseDouble("1.1111"), Double.parseDouble("-1.1111"), "Water: €" +waterPrice , "Food: €" + foodPrice , "Address: Manchester"));
I was wondering, would it be possible to define an array with 5 values such as:
[1.33, 1.23, 1.24, 1.99, 2.01];
And then when the map is loaded first, it takes the value at index 0, assigns it to waterPrice, and then after I click a button or after 5 seconds has passed, it moves on to index 1, index 2 etc and sending this new price to the marker each the time button is clicked. So instead of having my waterPrice
and foodPrice
defined above, I can just iterate through the array, and send the value to the marker.
Could I use two arrays, one for waterPrice and one for foodPrice so that I can assign waterPrice
to index 0 in the array?
Sorry if what I am trying to explain is not really clear, if anyone could help me I would appreciate it. I'm stuck at the moment trying to come up with a way to implement this.