ViewFlipper не отображается в пользовательском DialogFragment

Я создал собственный DialogFragment, который загружает пользовательский макет с именем student_info_main_container. Этот макет содержит ViewFlipper, который я загружаю с двумя дополнительными макетами. Проблема в том, что ViewFlipper не отображается в моем DialogFragment, но остальная часть макета student_info_main_container отображается. Большая часть моей работы выполняется в OnCreateView. Любая помощь будет оценена.

public class StudentInfoUIViewController : DialogFragment, IJoinClassView
    {
        private ViewFlipper studentInfoContentFlipper;

        public static StudentInfoUIViewController NewInstance() 
        {
            StudentInfoUIViewController frag = new StudentInfoUIViewController();     
            frag.SetStyle(DialogFragmentStyle.NoTitle, 0);

            return frag;
        }

        public override void OnAttach(Activity activity)
        {
            base.OnAttach(activity);
            Log.Debug("StudentInfoUIViewController", "OnAttach Called.");
        }

        //This is called to create the view and initialize the UI.  The UI isn't made visible until OnStart is called.
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
        {
            Dialog.Window.SetGravity(GravityFlags.Top);

            //Inflate and set the main layout for this DialogFragment
            View mainView = inflater.Inflate(Resource.Layout.student_info_main_container, container, true);

            //Find the ViewFlipper in the mainView
            studentInfoContentFlipper = Activity.FindViewById<ViewFlipper>(Resource.Id.studentInfoMainContainer_viewFlipper_studentInfoContent);

            //Inflate the layouts that are going to be added to the studentInfoContentFlipper ViewFlipper
            View joinSelectionView = inflater.Inflate(Resource.Layout.student_info_join_selection, null);
            View test = inflater.Inflate(Resource.Layout.test, null);

            //Add the above views to the flipper.
            studentInfoContentFlipper.AddView(joinSelectionView, 0);
            studentInfoContentFlipper.AddView(test, 1);


            Log.Debug("StudentInfoUIViewController", "OnCreateView Called.");

            return mainView;
        }

        public override void OnStart()
        {
            base.OnStart();
            //UI is visible
            Log.Debug("StudentInfoUIViewController", "OnStart Called.");

        }               

    }

1 ответ

Решение

Не ищите ViewFlipper в Activityпросто найдите его в раздутом виде (mainView), который станет видом для Fragment, Также не используйте Inflate() метод с boolean параметр установлен в true поскольку это добавит раздутое представление к контейнеру, которое будет выполнено системой автоматически после onCreateView возвращается.

Другие вопросы по тегам