Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - SupportMapFragment error when openning for second time
    primarykey
    data
    text
    <p>I'm using Fragment(with TabHost) in my application. When opening my SupportMapFragment (Android maps v2) for a second time, I get the following error:</p> <pre><code>FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #48: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) at android.view.LayoutInflater.inflate(LayoutInflater.java:489) at android.view.LayoutInflater.inflate(LayoutInflater.java:396) </code></pre> <p>My main Fragment Class:</p> <pre><code>FragmentManager fm = getFragmentManager(); if (tabId.equals("1")) fm.beginTransaction().replace(R.id.fragment1, new Fragment1(), tabId).commit(); if (tabId.equals("2")) fm.beginTransaction().replace(R.id.fragment2, new Fragment2(), tabId).commit(); </code></pre> <p>XML File:</p> <pre><code>&lt;fragment android:id="@+id/mapview" android:layout_width="match_parent" android:layout_height="342dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" class="com.google.android.gms.maps.SupportMapFragment" /&gt; </code></pre> <p>Fragment1 class:</p> <pre><code>public class Fragment1 extends SupportMapFragment { public void onCreate(Bundle arg0) { super.onCreate(arg0); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); view = inflater.inflate(R.layout.activity_map_event, container, false); // Error occurs in this line when I called second time. view.setId(getId()); SupportMapFragment fm = (SupportMapFragment) getActivity() .getSupportFragmentManager().findFragmentById(R.id.mapview); mapView = fm.getMap(); initMap(); return view; } public void onDestroyView() { super.onDestroyView(); SupportMapFragment fragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.mapview); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); ft.remove(fragment); ft.commit(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload