2

I have a problem , I can use a MapView and I see the map correctly :

 <com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/>

but when I use a MapFragment the app crash...Error inflating class fragment:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"/>

The main.java it's only :

public class situar_mapav3 extends android.support.v4.app.FragmentActivity{

    public situar_mapav3() {


    }
        @Override
        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
     }

Any idea ? Thanks.

sdelatorre
  • 67
  • 1
  • 11

2 Answers2

3

You have to extend com.google.android.gms.maps.SupportMapFragment instead of android.support.v4.app.FragmentActivity

Analizer
  • 1,594
  • 16
  • 30
0

try to use this layout, and plz post you logcat logs, will help to understand problem better

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapParent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
umesh
  • 1,148
  • 1
  • 12
  • 25