Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从SQLite中检索数据数组,从数组中检索属性,将属性添加到数组中并创建多段线_Java_Android_Arrays_Sqlite - Fatal编程技术网

Java 从SQLite中检索数据数组,从数组中检索属性,将属性添加到数组中并创建多段线

Java 从SQLite中检索数据数组,从数组中检索属性,将属性添加到数组中并创建多段线,java,android,arrays,sqlite,Java,Android,Arrays,Sqlite,我可以使用routeID、routeName、lat和lng从数据库中检索列表,如下所示: DatabaseRouteHelper db = new DatabaseRouteHelper(this); List<Route> routesWithSameID; Intent routeID = getIntent(); int routeid = routeID.getIntExtra("routeID", 0); routesWithSa

我可以使用
routeID
routeName
lat
lng
从数据库中检索列表,如下所示:

    DatabaseRouteHelper db = new DatabaseRouteHelper(this);
    List<Route> routesWithSameID;
    Intent routeID = getIntent();
    int routeid = routeID.getIntExtra("routeID", 0);

    routesWithSameID = db.getAllRoutesWithSameID(routeid);
DatabaseRouteHelper db=新的DatabaseRouteHelper(此);
列出带有sameid的路由;
Intent routeID=getIntent();
int routeid=routeid.getIntExtra(“routeid”,0);
routesWithSameID=db.getAllRoutesWithSameID(routeid);
我想知道如何提取所有lat和LNG(
getLat()
getLng()

然后将它们添加到另一个数组列表中,这样它就只有lat和lngs,我才能创建一条多段线?

好的,我已经找到了,只需要遍历数组,获取值,解析em并添加到LatLng数组中,如下所示:

List<LatLng> latLng = new ArrayList<LatLng>();

for (int i = 0; i < routesWithSameID.size(); i++){
            String latString = routesWithSameID.get(i).getLat();
            String lngString = routesWithSameID.get(i).getLng();
            double latitude = Double.parseDouble(latString);
            double longitude = Double.parseDouble(lngString);
            LatLng location = new LatLng(latitude, longitude);
            latLng.add(location);
        }
List latLng=new ArrayList();
对于(int i=0;i