我已经阅读了很多文章,但没有一篇可以解决我没有在 XMLParsingExample 类中调用 onCreate 方法的问题。
onCreate 中的日志语句没有显示输出,跟踪显示类在 boolean finished=false 后退出,因此没有运行 onCreate。
这里的代码:
public class MyMap extends MapActivity {
private MapView mapView;
private MapController mc;
private OverlayItem overlayItem;
private List<Overlay> mapOverlays;
private Drawable drawable;
private Drawable drawable2;
private MyItemizedOverlay itemizedOverlayMyLoc;
private MyItemizedOverlay itemizedOverlayRust;
private LocationManager locMgr;
private MyLocationListener locLstnr;XMLParsingExample mXMLParsingExample;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mc = mapView.getController();
mapView.setBuiltInZoomControls(true);
locMgr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locLstnr = new MyLocationListener();
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locLstnr);
mapOverlays = mapView.getOverlays();
// first overlay
drawable = getResources().getDrawable(R.drawable.marker2);
itemizedOverlayMyLoc = new MyItemizedOverlay(drawable, mapView);
// LAT LONG
GeoPoint uwLoc = new GeoPoint((int)(52.22778*1E6),(int)(6.10428*1E6));
overlayItem = new OverlayItem(uwLoc, "Uw locatie", "http://www.nu.nl");
itemizedOverlayMyLoc.addOverlay(overlayItem);
mapOverlays.add(itemizedOverlayMyLoc);
// Rustpunten overlay
drawable2 = getResources().getDrawable(R.drawable.rmarker3);
itemizedOverlayRust = new MyItemizedOverlay(drawable2, mapView);
mXMLParsingExample = new XMLParsingExample();
这里是未调用 oncreate 的类:
public class XMLParsingExample extends Activity {
/** Create Object For SiteList Class */
public SitesList sitesList = null;
public ProgressDialog progressDialog;
boolean finished=false;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i("onCreate", "onCreate started");
}