[英]How read elements from ArrayList<List<LatLng>>
我正在使用 Android Studio,并且在名为 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;
}
}
在 MainActiviy 我有这个代码。 我知道这不是从数组中读取每个元素的正确方法。 这是我试图从旧代码中修改的东西,但是读取每个元素的正确方法是什么。
public ArrayList<List<LatLng>> perimetroArray;
perimetroArray = newClassObj.getArrayPerimetro();
Polygon polygon2 = googleMap.addPolygon(new PolygonOptions()
.clickable(true)
.strokeColor(0x7700ff00)
.add(perimetroArray.toArray(new LatLng[0])));
任何人都可以帮助我。 谢谢
好的,我又来了。 给您带来的不便很抱歉,我自己找到了答案,但我还是会发布它,希望这些信息对其他人有用。 读取数组中每个元素的正确方法如下:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.