To show a fragment, it typically looks like the following:
var transaction = FragmentManager.BeginTransaction();
var fragment = new MyFragment();
fragment.Show(transaction, Tag);
You will want to have a layout container that you'd like the fragment to replace, I use a utility function like so (named better ):
public static Fragment ShowMyFragment(FragmentManager manager, int containerId, string tagId)
{
var ft = manager.BeginTransaction();
// remove existing copies of fragment
var prev = manager.FindFragmentByTag(tagId);
if (prev != null)
ft.Remove(prev);
var fragment = MyFragment.NewInstance(containerId, tagId);
ft.Replace(containerId, fragment, tagId);
ft.Commit();
return fragment;
}
Answers
Hello.
I have a similar problem here https://forums.xamarin.com/discussion/95546/how-to-add-a-fragment-in-customadapter#latest.
Did you find a solution ?
To show a fragment, it typically looks like the following:
You will want to have a layout container that you'd like the fragment to replace, I use a utility function like so (named better
):