Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/356.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 使用数组列表向Google地图添加标记。安卓_Java_Android_Arrays_Android Maps V2 - Fatal编程技术网

Java 使用数组列表向Google地图添加标记。安卓

Java 使用数组列表向Google地图添加标记。安卓,java,android,arrays,android-maps-v2,Java,Android,Arrays,Android Maps V2,我正在尝试将数据库中的值捕获到数组列表中。我只想得到创建标记的纬度和经度 这是我在db处理程序类中的gettemple()函数 public ArrayList<kovil> Get_Temple(String temple_type, String Limit) { try { temple_list.clear(); // Select All Query String selectQuery = "SELECT * FROM " + TABLE_TE

我正在尝试将数据库中的值捕获到数组列表中。我只想得到创建标记的纬度和经度

这是我在db处理程序类中的gettemple()函数

public ArrayList<kovil> Get_Temple(String temple_type, String Limit) {
try {
    temple_list.clear();

    // Select All Query
    String selectQuery = "SELECT  * FROM " + TABLE_TEMPLE +"WHERE KEY_TMPTYPE=" + temple_type +"LIMIT" + Limit;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);
    System.out.print("CALLED");
    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
    do {
        kovil Kovil = new kovil();
        Kovil.setID(Integer.parseInt(cursor.getString(0)));
        Kovil.settemplename(cursor.getString(1)); 
        Kovil.settempletype(cursor.getString(2)); 
        Kovil.setlatitude(cursor.getString(3)); 
        Kovil.setlongitude(cursor.getString(4)); 
        Kovil.setimage_name(cursor.getString(5)); 
        Kovil.setyear_build(cursor.getString(6)); 
        Kovil.setaddress(cursor.getString(7)); 
        Kovil.setcity(cursor.getString(8)); 
        Kovil.setemail(cursor.getString(9)); 
        Kovil.setwebsite(cursor.getString(10)); 
        Kovil.settelephone1(cursor.getString(11)); 
        Kovil.settelephone2(cursor.getString(12));
        Kovil.setDescription(cursor.getString(13));

        // Adding contact to list
        temple_list.add(Kovil);
    } while (cursor.moveToNext());
    }

    // return contact list
    cursor.close();
    db.close();
    return temple_list;
} catch (Exception e) {
    // TODO: handle exception
    Log.e("all_temples", "" + e);
}

return temple_list;
}
    dbhand.Get_Temple((getIntent().getExtras().getString("temple_type")), getIntent().getExtras().getString("notemples"));


            for (int i=0; i< Integer.parseInt(getIntent().getExtras().getString("notemples"));i++) {
                //displaytemples(9.662502, 80.010239, "mugan kovil");

            }
public boolean displaytemples(double lati, double longi, String templename){

    MarkerOptions marker = new MarkerOptions().position(new LatLng(lati, longi)).title(templename);
    marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon));
    //marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
    mMap.addMarker(marker);


    return true;
}
我只想从数组列表中获取纬度和经度,并使用该for循环将纬度和经度传递给displayTemplates()


有谁能帮我写一个for循环,它只捕捉纬度和经度,并将它传递给
displaytimges()
函数。谢谢你…

老实说,你的代码让我很害怕。。。但这是不同的问题。我要指出的唯一一点是,请不要从主线程获取DB。您正以这种方式阻止UI:(.查看
AsyncTask
或其他一些将DB操作从主线程卸载的方法。)

至于您的问题,您可以尝试以下方法:

ArrayList<kovil> data = dbhand.Get_Temple(getIntent().getExtras().getString("temple_type"), 
                                          getIntent().getExtras().getString("notemples"));


for (kovil temple: data) {
    displaytemples(Double.parseDouble(temple.getlatitude(), 
                                      temple.getlongitude(), 
                                      temple.gettemplename());

}
ArrayList data=dbhand.Get_Temple(getIntent().getExtras().getString(“Temple_type”),
getIntent().getExtras().getString(“notemples”);
用于(科维尔神庙:数据){
DisplayTemplates(Double.parseDouble(temple.getlatitude()),
temple.getlongitude(),
temple.gettemplename());
}
检查此帮助的链接。请参考它。
ArrayList<kovil> data = dbhand.Get_Temple(getIntent().getExtras().getString("temple_type"), 
                                          getIntent().getExtras().getString("notemples"));


for (kovil temple: data) {
    displaytemples(Double.parseDouble(temple.getlatitude(), 
                                      temple.getlongitude(), 
                                      temple.gettemplename());

}