Fragmentmanager Crashes When Using Replace
I have an Activity and few Fragments. I have to replace fragment in FrameLayout. But when I'm using this function my app crashes. Here is the code of function Android.Support.V4.Ap
Solution 1:
I am not certain based on this snipit, but if you are trying to access an Android resource Id such as mentioned by the previous person, you need to use Android.Resource.Id in Xamarin.
If this is not what you want, I would ask if you have a FrameLayout inside your desired container with the id content_frame.
I designed my layout and include a FrameLayout which is what I switch in and out of using the SupportFragmentManager.
Solution 2:
Android.Support.V4.App.Fragmentfragment=null;
switch (position) {
case0:
fragment = newScheduleFragment();
break;
case1:
fragment = newMainFragment();
break;
}
if (fragment != null) {
Android.Support.V4.App.FragmentManagerfragmentManager= SupportFragmentManager;
vartransaction= fragmentManager.BeginTransaction();
// ---- change this line ---- //
transaction.Replace(R.id.content_frame, fragment);
transaction.Commit();
mDrawerList.SetItemChecked (position, true);
SetTitle (mScreenTitles [position]);
mDrawerLayout.CloseDrawer (mDrawerList);
} else {
Log.Error (this.Class.Name, "Error, fragment not created");
}
Post a Comment for "Fragmentmanager Crashes When Using Replace"