In my Android app, I am iterating through an array of locations and adding a map marker for each item. I would like to use a different marker icon for each item in the array. There are 30 items in the locations array and 30 different icons. The icon file names are icon1.png, icon2.png, icon3.png etc.
My code is as follows:
for (int i = 1; i < myArray.size(); i ++) {
marker = mMap.addMarker(new MarkerOptions()
.position(myArray.get(i))
.title("Marker " + i)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon1)));
}
How can I set R.drawable.icon1 to change for each iteration? i.e. R.drawable.icon(i)