locked
How to add a fragment in customAdapter RRS feed

  • Question

  • User320645 posted

    Hello.

    I am using a public class CustomAdapter :BaseAdapter class.

    When I try to add a fragment to one of the button.click event i get this error

    Do I have to install Xamarin.Android.Support.v4.AppCompat or there is another problem ? I have already installed Xamarin.Android.Support.v7.AppCompat ?

    This is my fragment class

    public class Edit_Fragment :DialogFragment { public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return base.OnCreateView(inflater, container, savedInstanceState);

            var view = inflater.Inflate(Resource.Layout.EditFragment, container, false);
    
            return view;
        }
    }
    
    Tuesday, May 16, 2017 9:37 AM

Answers

  • User320645 posted

    I found the solution.

    It must be

    FragmentTransaction trans = ((Activity)_mContex).FragmentManager.BeginTransaction(); EditFragment fragment = new EditFragment(); fragment.Show(trans, "edit fragment");

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, May 16, 2017 2:52 PM