我收到此错误:The method getSupportFragmentManager() is undefined for the type MainActivity.当我将语句更改为:
SupportMapFragment fm = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.map);
Run Code Online (Sandbox Code Playgroud)
然后我收到这个错误:
Multiple markers at this line
- Cannot cast from Fragment to
SupportMapFragment
- Line breakpoint:MainActivity [line: 52] -
onCreate(Bundle)
Run Code Online (Sandbox Code Playgroud)
源代码:
package in.wptrafficanalyzer.proximitymapv2;
import android.app.Activity;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMapClickListener;
import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import …Run Code Online (Sandbox Code Playgroud)