0
我想从数据库中捕捉数值到数组列表中。我只想获得创建标记的纬度和经度。使用数组列表将标记添加到Google地图。 Android
这里是我的gettemple()在DB处理类
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;
}
功能,这将在同一类返回temple_list阵列。
private final ArrayList<kovil> temple_list = new ArrayList<kovil>();
,并试图调用查看地图类Get_Temple()函数
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;
}
我来显示标记只想捕获数组列表中的纬度和经度,并使用该循环我想要pa将displaytemples()的经度和纬度ss。
任何人都可以帮我写for循环,它只捕获经纬度并将其传递给displaytemples()
函数。谢谢你...
检查HTTP ://stackoverflow.com/questions/21360320/android-arraylist-how-to-use链接希望这个帮助,参考它。 –