protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView(Resource.Layout.action_bar_fragment_menu); // Make sure the two menu fragments are created. var fm = SupportFragmentManager; var ft = fm.BeginTransaction(); mFragment1 = (MenuFragment)fm.FindFragmentByTag("f1"); if (mFragment1 == null) { mFragment1 = new MenuFragment(); ft.Add(mFragment1, "f1"); } mFragment2 = (Menu2Fragment)fm.FindFragmentByTag("f2"); if (mFragment2 == null) { mFragment2 = new Menu2Fragment(); ft.Add(mFragment2, "f2"); } ft.Commit(); // Watch check box clicks. mCheckBox1 = (CheckBox)FindViewById(Resource.Id.menu1); mCheckBox1.Click += OnClickListener_OnClick; mCheckBox2 = (CheckBox)FindViewById(Resource.Id.menu2); mCheckBox2.Click += OnClickListener_OnClick; mCheckBox3 = (CheckBox)FindViewById(Resource.Id.menu3); mCheckBox3.Click += OnClickListener_OnClick; mHasOptionsMenu = (CheckBox)FindViewById(Resource.Id.has_options_menu); mHasOptionsMenu.Click += OnClickListener_OnClick; mMenuVisibility = (CheckBox)FindViewById(Resource.Id.menu_visibility); mMenuVisibility.Click += OnClickListener_OnClick; // Make sure fragments start out with correct visibility. UpdateFragmentVisibility(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.action_bar_fragment_menu); // Make sure the two menu fragments are created. var fm = SupportFragmentManager; var ft = fm.BeginTransaction(); mFragment1 = (MenuFragment)fm.FindFragmentByTag("f1"); if (mFragment1 == null) { mFragment1 = new MenuFragment(); ft.Add(mFragment1, "f1"); } mFragment2 = (Menu2Fragment)fm.FindFragmentByTag("f2"); if (mFragment2 == null) { mFragment2 = new Menu2Fragment(); ft.Add(mFragment2, "f2"); } ft.Commit(); // Watch check box clicks. mCheckBox1 = (CheckBox)FindViewById(Resource.Id.menu1); mCheckBox1.Click += OnClickListener_OnClick; mCheckBox2 = (CheckBox)FindViewById(Resource.Id.menu2); mCheckBox2.Click += OnClickListener_OnClick; mCheckBox3 = (CheckBox)FindViewById(Resource.Id.menu3); mCheckBox3.Click += OnClickListener_OnClick; mHasOptionsMenu = (CheckBox)FindViewById(Resource.Id.has_options_menu); mHasOptionsMenu.Click += OnClickListener_OnClick; mMenuVisibility = (CheckBox)FindViewById(Resource.Id.menu_visibility); mMenuVisibility.Click += OnClickListener_OnClick; // Make sure fragments start out with correct visibility. UpdateFragmentVisibility(); }