The Map Doesn't Show, only show Grid, and Show Grey Background

后端 未结 5 1999
感动是毒
感动是毒 2020-12-22 12:03

i just want to ask i want to make googlemaps apps on android.. i have follow instruction from many website (include from google developer) but the apps doesn\'t work on my r

5条回答
  •  猫巷女王i
    2020-12-22 12:26

    Use MapView in your xml

     
    

    and Use the below code for the GoogleActivity:

    public class GoogleActivity extends Activity {
        private GoogleMap mGglMpInstance;
        private MapView mMapView;
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);
                try {
                    MapsInitializer.initialize(MainActivity.this);
                } catch (GooglePlayServicesNotAvailableException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } 
                initailizeLayout(savedInstanceState);
            }
    
            private void initailizeLayout(Bundle savedInstanceState){
                mMapView=(MapView)findViewById(R.id.mMapView);
                mMapView.onCreate(savedInstanceState);
                mGglMpInstance=mMapView.getMap();
        }
    

提交回复
热议问题