I know this question has been asked too much here but i ahve tried every solution out there to open a fragment from another fragment and no one worked for me.
Fr
You need a FrameLayout
to contain your LinearLayout
:
And your code should be :
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
var view = inflater.Inflate(Resource.Layout.my_layout, container, false);
var ll = view.FindViewById(Resource.Id.ll);
var bt = view.FindViewById(Resource.Id.addbtn);
bt.Click+= delegate
{
Fragment2 fragment2 = new Fragment2();
FragmentTransaction ft = FragmentManager.BeginTransaction();
ft.Replace(Resource.Id.content_frame, fragment2);
ft.Commit();
ll.Visibility = ViewStates.Gone;
};
return view;
}
You can refer to this to see why your fragment2
just top on it. I use ll.Visibility = ViewStates.Gone;
to avoid it.