5

我正在尝试显示地图,但它显示此错误,“方法 getSupportFragmentMananger() 未定义为 main 类型”请帮助。谢谢。我正在使用谷歌地图应用程序

package com.maps;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;



import android.app.Activity;

public class main extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        GoogleMap mMap;
        mMap = ((MapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

        //can pass dynamic variables
        final LatLng place = new LatLng(-37.81319, 144.96298);
       Marker melbourne = mMap.addMarker(new MarkerOptions()
                                  .position(place)
                                  .title("Melbourne")
                                  .snippet("Population: 4,137,400")
                                  .icon(BitmapDescriptorFactory.fromResource(android.R.drawable.bottom_bar)));


    }
}
4

1 回答 1

17
public class main extends Activity

你应该使用AppCompatActivityor FragmentActivity,例如

public class mai extends AppCompatActivity

代替

public class main extends Activity
于 2013-05-06T09:59:21.127 回答