Forum Xamarin.Android

How to add a fragment in customAdapter

TripleDoubleTripleDouble BGMember ✭✭✭

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;
    }
}
Tagged:

Best Answer

  • TripleDoubleTripleDouble BGMember ✭✭✭
    Accepted Answer

    I found the solution.

    It must be

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

Answers

  • TripleDoubleTripleDouble BGMember ✭✭✭
    Accepted Answer

    I found the solution.

    It must be

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

Sign In or Register to comment.