vlio20
vlio20

Reputation: 9295

Exception when inflating fragment with google map v2

I having this fragment:

import android.app.Fragment;
public class MapsFragment extends Fragment
{   
    View rootView;
    GoogleMap map;

    AutoCompleteTextView addressInput;
    ProgressDialog progressDialog;

    FindMapLocationTask findMapLocationTask;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
    {
        if (rootView != null) 
        {
            ViewGroup parent = (ViewGroup) rootView.getParent();
            if (parent != null)
                parent.removeView(rootView);
        }
        try 
        {
            rootView = inflater.inflate(R.layout.map_frag, container, false);
        } 
        catch (InflateException e) 
        {
            return rootView;
        }
            ...

and here is map_frag.xml:

<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" >

    <AutoCompleteTextView
        android:id="@+id/map_frag_location_AutoCompleteTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:ems="10" >

        <requestFocus />
    </AutoCompleteTextView>

    <fragment
        android:id="@+id/map_frag_map_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/map_frag_location_AutoCompleteTextView"
        android:layout_alignParentLeft="true"
        class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>

I am getting exception and falling into this catch: return rootView;. The exeption message is android.view.InflateException: Binary XML file line #18: Error inflating class fragment. What is wrong?

Upvotes: 0

Views: 393

Answers (1)

tyczj
tyczj

Reputation: 73753

continuing from your last question you have a similar problem "com.google.android.gms.maps.SupportMapFragment" needs to be com.google.android.gms.maps.MapFragment since you are no longer using SupportMapFragment and using MapFragment

plus your fragment needs to extend MapFragment not Fragment

Upvotes: 2

Related Questions