in my application i'm loading map in navigation drawer fragment class. first time when i'm opening map fragment its showing me map but on second time following fatal exception-
E/AndroidRuntime(5881): java.lang.IllegalArgumentException: No view found for id 0x7f050025 (com.example.myapp:id/mapfragment) for fragment Fragment{41d89968 #1 id=0x7f050025}
xml code-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/mapfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
java code-
View v;
Fragment mf;
MapFragment m;
private GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
//Fragment videoFragment = new DealerLocations();
v = inflater.inflate(R.layout.map, container, false);
} catch (InflateException e) {
}
Fragment mf = new Fragment();
mf.getFragmentManager();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.mapfragment, mf).commit();
m= (MapFragment) getActivity().getFragmentManager().findFragmentById(R.id.mapfragment);
map = m.getMap();
}
I also wend through many links like- When inflating fragment which was previously inflated app crashes , Android, java.lang.IllegalArgumentException: No view found for id [..] for fragment [..] but not getting solution. Is there any solution for this?