WEB开发网
开发学院手机开发Android 开发 Android 数据库与MapView总结 阅读

Android 数据库与MapView总结

 2010-11-05 00:54:34 来源:WEB开发网   
核心提示:/* 系统选择餐馆 */drawRestaurant();}private void drawRestaurant() {String f[] = { "f_id", "f_name", "f_address", "f_cal"};/* S

/* 系统选择餐馆 */

drawRestaurant();

}

private void drawRestaurant() {

String f[] = { "f_id", "f_name", "f_address", "f_cal"};

/* SELECT f[] FROM tables[0] */

Cursor c = dbHelper.select

(

tables[0], f, "", null, null, null, null

);

allRestaurantID = new ArrayList();

allRestaurantName = new ArrayList();

allRestaurantAddress = new ArrayList();

allRestaurantCal = new ArrayList();

/* 将所有餐厅数据放入List对象 */

while (c.moveToNext())

{

allRestaurantID.add(c.getString(0));

allRestaurantName.add(c.getString(1));

allRestaurantAddress.add(c.getString(2));

allRestaurantCal.add(c.getString(3));

}

if(allRestaurantID.size()>0)

{

Random generator = new Random();

int intThrowIndex = generator.nextInt(allRestaurantID.size());

mTextView01.setText

(

allRestaurantName.get(intThrowIndex)+" "+

allRestaurantAddress.get(intThrowIndex)+" "+

allRestaurantCal.get(intThrowIndex)+

getResources().getText(R.string.str_cal)

);

/* 以地址查询地理坐标 */

GeoPoint gp =

getGeoByAddress(allRestaurantAddress.get(intThrowIndex));

if(gp==null)

{

/* 地址无法反查为GeoPoint时 */

mMapView01.setVisibility(MapView.GONE);

}

else

{

/* 更新MapView地图 */

mMapView01.setVisibility(MapView.VISIBLE);

showImageOverlay(gp);

refreshMapViewByGeoPoint

(

getGeoByAddress(allRestaurantAddress.get(intThrowIndex)),

mMapView01, intZoomLevel, true

);

}

}

else

{

/* 数据库无记录 */

上一页  19 20 21 22 23 24 25 26 27 28 29  下一页

Tags:Android 数据库 MapView

编辑录入:coldstar [复制链接] [打 印]
赞助商链接