app not accepting gmap in xml file

后端 未结 3 748
误落风尘
误落风尘 2020-12-12 03:13

I am developing app based on gmap.

For that i am following this doccument.

Its giving me error on mainactivity.xml for following code:



        
相关标签:
3条回答
  • 2020-12-12 03:31
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
    
    
    <fragment 
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          class="com.google.android.gms.maps.SupportMapFragment"/>
    
    </RelativeLayout>
    
    0 讨论(0)
  • 2020-12-12 03:34

    Try this SupportMapFragment instead of MapFragment in last line also look your fragment tag.

    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout 
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
    
    
     <fragment 
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>
    
    </RelativeLayout>
    

    Refer this Example

    0 讨论(0)
  • 2020-12-12 03:37

    remove it from fragment class in your xml :

    xmlns:android="http://schemas.android.com/apk/res/android"
    

    Not sure if I'm helpful here but i only declare the Namespace once in my case in the

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >
    
      <fragment class="com.blablabla.MyFragment"
            android:id="@+id/fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
     </RelativeLayout>
    
    0 讨论(0)
提交回复
热议问题