0
我主類的類調用一個活動是主要的擴展活動如何從擴大ItemizedOverlay
與此代碼調用MiMapa類:
switch(v.getId()){
case R.id.presentLocation_button:
Log.i("Button","Button 3 pushed");
Intent m = new Intent(this, MiMapa.class);
startActivity(m);
break;
工作完美。
MiMapa類是:
public class MiMapa extends MapActivity implements LocationListener {
我有這樣的方法:
public void setOverlay1(){
int foodLength = foodItem.length;
// Create itemizedOverlay2 if it doesn't exist and display all three items
if(! foodIsDisplayed){
mapOverlays = mapView.getOverlays();
drawable1 = this.getResources().getDrawable(R.drawable.golf);
itemizedOverlay1 = new Ofertas(drawable1);
// Display all three items at once
for(int i=0; i<foodLength; i++){
itemizedOverlay1.addOverlay(foodItem[i]);
}
mapOverlays.add(itemizedOverlay1);
foodIsDisplayed = !foodIsDisplayed;
// Remove each item successively with button clicks
} else {
itemizedOverlay1.removeItem(itemizedOverlay1.size()-1);
if((itemizedOverlay1.size() < 1)) foodIsDisplayed = false;
}
// Added symbols will be displayed when map is redrawn so force redraw now
mapView.postInvalidate();
}
現在的問題。
到Ofertas類(公共類Ofertas擴展ItemizedOverlay {)
在自來水方法我的代碼是:
protected boolean onTap(int i){
GeoPoint gpoint = myOverlays.get(i).getPoint();
double lat = gpoint.getLatitudeE6()/1e6;
double lon = gpoint.getLongitudeE6()/1e6;
String toast = "Title: "+myOverlays.get(i).getTitle();
toast += "\nText: "+myOverlays.get(i).getSnippet();
toast += "\nSymbol coordinates: Lat = "+lat+" Lon = "+lon+" (microdegrees)";
Toast.makeText(principal.context, toast, Toast.LENGTH_LONG).show();
Intent intent = new Intent();
intent.setClass(principal.context,Popup.class);
principal.context.startActivity(intent);
intent.putExtra("message", "My popup number " + mCount);
mCount++;
//startActivity(intent);
return(true);
}
,但不起作用。我試過 intent.setClass(MiMapa.context,Popup.class); 或 intent.setClass(principal.this,Popup.class); 或 intent.setClass(MiMapa.this,Popup.class);
沒有工作。
請幫幫我。
感謝