I have a fragment that most of it's layout is creating programmatically.
First time that fragment appears everything is OK but when I open another fragment and press back button I got IllegalArgumentException.
Please note that Just when I press back button this issue happens , When I call popBackStack everything is ok.
Any suggestion ?
Code :
if(mapView != null)
{
ViewGroup parent = (ViewGroup) mapView.getParent();
if (parent != null)
{
parent.removeView(mapView);
}
}
try
{
// Creating view
mapView = getBaseActivity().getLayoutInflater().inflate(R.layout.property_show_map_section, (ViewGroup) view, false);
}
catch(Exception e)
{
}
((LinearLayout)view.findViewById(R.id.section_container)).addView(mapView);
final SupportMapFragment googleMap = new SupportMapFragment();
getChildFragmentManager().beginTransaction()
.replace(R.id.map_container, googleMap).commit();
LogCat :
03-19 18:28:40.229: E/AndroidRuntime(6850): FATAL EXCEPTION: main
03-19 18:28:40.229: E/AndroidRuntime(6850): java.lang.IllegalArgumentException: No view found for id 0x7f0b00e4 (com.example.app:id/map_container) for fragment SupportMapFragment{53056b1c #0 id=0x7f0b00e4}
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:939)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1917)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1800)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:967)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:957)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1541)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl$2.run(FragmentManager.java:493)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.os.Handler.handleCallback(Handler.java:730)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.os.Handler.dispatchMessage(Handler.java:92)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.os.Looper.loop(Looper.java:137)
03-19 18:28:40.229: E/AndroidRuntime(6850): at android.app.ActivityThread.main(ActivityThread.java:5103)
03-19 18:28:40.229: E/AndroidRuntime(6850): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 18:28:40.229: E/AndroidRuntime(6850): at java.lang.reflect.Method.invoke(Method.java:525)
03-19 18:28:40.229: E/AndroidRuntime(6850): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-19 18:28:40.229: E/AndroidRuntime(6850): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-19 18:28:40.229: E/AndroidRuntime(6850): at dalvik.system.NativeStart.main(Native Method)