ListView in Dialog Fragment RRS feed

  • Question

  • User136765 posted


    i created dialog fragment and i want when user click the button the dialog fragment show list view , how can i do this ?

    Thursday, March 17, 2016 5:25 PM

All replies

  • User320645 posted


    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 ?

    Tuesday, May 16, 2017 2:16 PM
  • User258468 posted

    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)
            var fragment = MyFragment.NewInstance(containerId, tagId);
            ft.Replace(containerId, fragment, tagId);
            return fragment;
    Tuesday, May 16, 2017 3:55 PM