Forum Xamarin.Android

ListView in Dialog Fragment

OmarMohOmarMoh USMember ✭✭
edited March 2016 in Xamarin.Android


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


  • TripleDoubleTripleDouble BGMember ✭✭✭


    I have a similar problem here

    Did you find a solution ?

  • cwphillicwphilli USMember ✭✭✭

    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;
Sign In or Register to comment.