Forum Xamarin.Android

Null Reference Exception on FragmentManager.BeginTransaction(). Fragment to Fragment

Inside of a fragment Im using a gridview to display an infinite list of image Buttons.
Inside the gridView BaseAdapter the Image Button Click call looks like this:
`imgThumbail.Click += (e, o) => {
Toast.MakeText(_context, "Img Button Clicked", ToastLength.Short).Show();

            Fragment fragment = new MyExpandedGridCell();
            FragmentTransaction fragmentTransaction = context.FragmentManager.BeginTransaction();
            fragmentTransaction.Replace(MainActivity.mainFragmentLayout, fragment);
            fragmentTransaction.AddToBackStack(null);
            fragmentTransaction.Commit();
        };`

On line FragmentTransaction fragmentTransaction = context.FragmentManager.BeginTransaction();
Im getting a null reference Exception.

The intended behavior is have the imageButton click replace the current Fragment with another Fragment. Does anyone know why this doesnt work?

Sign In or Register to comment.