Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.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
Android 如何从扩展ItemizeOverlay的类调用活动_Android_Popup - Fatal编程技术网

Android 如何从扩展ItemizeOverlay的类调用活动

Android 如何从扩展ItemizeOverlay的类调用活动,android,popup,Android,Popup,我的主课是校长活动 使用此代码调用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类是

我的主课是校长活动

使用此代码调用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(); 
    }
但是不要工作。 我试过了 context,Popup.class; 或 intent.setClassprincipal.this,Popup.class; 或 intent.setClassMiMapa.this,Popup.class

没用

请帮帮我

谢谢

将您的活动传递到ItemizedOverlay,例如通过构造函数,并将其用于startActivity调用

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);
    }