我创建了一个自定义 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.");
}
}