I'm working with Android Studio and I have the following code in a public class named Coordenadas
public class Coordenadas {
public ArrayList<List<LatLng>> getArrayPerimetro() {
ArrayList<List<LatLng>> getArrayPrueba= new ArrayList<>();
getArrayPrueba.add(0,PolyUtil.decode("xbgrEl}jcJaAgYjUq@Dd[oSK"));
getArrayPrueba.add(1,PolyUtil.decode("zxnqElyyeJcC_JxFwE~BlIuFhF"));
return getArrayPrueba;
}
}
In MainActiviy I have this code. I know that this is not the correct way to read each element from the array. This is something I am trying to modify from an old code, but what would be the correct way to read each element.
public ArrayList<List<LatLng>> perimetroArray;
perimetroArray = newClassObj.getArrayPerimetro();
Polygon polygon2 = googleMap.addPolygon(new PolygonOptions()
.clickable(true)
.strokeColor(0x7700ff00)
.add(perimetroArray.toArray(new LatLng[0])));
Could anyone help me. Thank you
Ok, here I am again. Sorry for the inconvenience, I found the answer by myself, but I'll publish it anyway, I hope the information will be useful to others. The correct way to read each element in the array is as follows:
perimetroArray = newClassObj.getArrayPerimetro();
Polygon polygon2 = googleMap.addPolygon(new PolygonOptions()
.clickable(true)
.strokeColor(0x7700ff00)
.add(perimetroArray.get(1).toArray(new LatLng[0]))); <<--- get(N) where N is the index number from the array
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.