Android 尽管有真实的代码,但映射属性在xml文件中不起作用

Android 尽管有真实的代码,但映射属性在xml文件中不起作用,android,eclipse,google-maps,dictionary,Android,Eclipse,Google Maps,Dictionary,运行地图应用程序时没有错误。不幸的是,当我在xml片段中添加一些属性时,它没有显示任何结果。我不知道为什么。我正在使用minSdkVersion=17和targetSdkVersion=21。 请帮帮我 这是Main.java public class MainActivity extends FragmentActivity { private static final int GPS_ERRORDIALOG_REQUEST = 9001; GoogleMap gmap;

运行地图应用程序时没有错误。不幸的是,当我在xml片段中添加一些属性时,它没有显示任何结果。我不知道为什么。我正在使用minSdkVersion=17和targetSdkVersion=21。 请帮帮我

这是Main.java

public class MainActivity extends FragmentActivity {

    private static final int GPS_ERRORDIALOG_REQUEST = 9001;
    GoogleMap gmap;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(servicesOk())
        {
            setContentView(R.layout.activity_map);

        if(InitMap())
        {
            Toast.makeText(this, "Ready to Map !", Toast.LENGTH_SHORT).show();
        }
        else
        {
            Toast.makeText(this, "Map not available !", Toast.LENGTH_SHORT).show();
        }
        }
        else{

    setContentView(R.layout.activity_main);
            }
    }
    public boolean servicesOk(){

        int isAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

        if(isAvailable == ConnectionResult.SUCCESS){

            return true;
        }
        else if(GooglePlayServicesUtil.isUserRecoverableError(isAvailable))
        {
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvailable, this, GPS_ERRORDIALOG_REQUEST);
            dialog.show();
        }
        else{

            Toast.makeText(this, "Cannot connect to the Google Play Services",
                    Toast.LENGTH_SHORT).show();
        }
        return false;
    }

    private boolean InitMap(){

        if(gmap== null)
        {

            SupportMapFragment mapFragment = 
        (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        gmap = mapFragment.getMap();
        }
        return(gmap != null);
    }
这是xml文件

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:map="http://schemas.android.com/apk/res-auto"
  android:name="com.google.android.gms.maps.SupportMapFragment"
  android:id="@+id/map"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  map:cameraBearing="112.5"
  map:cameraTargetLat="-33.796923"
  map:cameraTargetLng="150.922433"
  map:cameraTilt="30"
  map:cameraZoom="13"
  map:mapType="satellite"
  map:uiCompass="false"
  map:uiRotateGestures="true"
  map:uiScrollGestures="false"
  map:uiTiltGestures="true"
  map:uiZoomControls="false"
  map:uiZoomGestures="true"/>

尝试使用
FrameLayout
而不是
Fragment
,并将
android:name=“com.google.android.gms.maps.SupportMapFragment”
更改为
class=“com.google.android.gms.maps.SupportMapFragment”

在活动中:

        _mapFrag = new SupportMapFragment();
        FragmentTransaction transaction = getSupportFragmentManager().BeginTransaction();
        transaction.Replace(Resource.Id.map, _mapFrag);
        transaction.Commit();

尝试使用
FrameLayout
而不是
Fragment
,并将
android:name=“com.google.android.gms.maps.SupportMapFragment”
更改为
class=“com.google.android.gms.maps.SupportMapFragment”

在活动中:

        _mapFrag = new SupportMapFragment();
        FragmentTransaction transaction = getSupportFragmentManager().BeginTransaction();
        transaction.Replace(Resource.Id.map, _mapFrag);
        transaction.Commit();

你可以通过编程方式添加这些属性,它们肯定会起作用。你可以发布解决方案,让其他人看到它吗亲爱的,我的意思是,在没有找到任何解决方案之后,我通过编程方式添加了这些属性。因此,你可以通过编程方式添加这些属性,它们肯定会起作用。你可以发布解决方案,以便其他人可以看到它吗亲爱的,我的意思是,在没有找到任何解决方案之后,我通过编程方式添加了这些属性。因此奏效了