本文整理汇总了C#中Fragment.SetHasOptionsMenu方法的典型用法代码示例。如果您正苦于以下问题:C# Fragment.SetHasOptionsMenu方法的具体用法?C# Fragment.SetHasOptionsMenu怎么用?C# Fragment.SetHasOptionsMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fragment
的用法示例。
在下文中一共展示了Fragment.SetHasOptionsMenu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
/* In case this activity is restored (i.e. hasn't been instanciated from
* our LandingActivity, we go there first to run the login logic run first.
* It's not pretty because we essentially incurs two activity change animations
* but it's easier for now.
*/
if (TabPerson.CurrentPerson == null) {
Finish ();
StartActivity (typeof (LandingActivity));
}
TabType.InitializeCache (this);
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
// If the current user hasn't been verified we launch a timer to reset it
if (!TabPerson.CurrentPerson.IsVerified) {
new AlertDialog.Builder (this)
.SetMessage ("You won't be able to fully use this application " +
"until you confirm your details via the email " +
"sent to " + TabPerson.CurrentPerson.LoginEmail)
.SetPositiveButton ("OK", delegate {}).Show ();
RefreshLoop (TabPerson.CurrentPerson);
}
// New Tab tab setup
var tab = ActionBar.NewTab ().SetText ("Add");
tab.TabSelected += (object sender, ActionBar.TabEventArgs e) => {
if (newTabFragment == null) {
newTabFragment = Fragment.Instantiate (this,
Class.FromType (typeof (ParticipantSelectionFragment)).Name);
e.FragmentTransaction.Add (Android.Resource.Id.Content, newTabFragment, "new-tab");
} else {
e.FragmentTransaction.Attach (newTabFragment);
}
};
tab.TabUnselected += (object sender, Android.App.ActionBar.TabEventArgs e) => {
if (newTabFragment != null)
e.FragmentTransaction.Detach (newTabFragment);
};
tab.TabReselected += (object sender, ActionBar.TabEventArgs e) => {
if (newTabFragment != null)
((ParticipantSelectionFragment)newTabFragment).Refresh ();
};
ActionBar.AddTab (tab);
// Activity setup
tab = ActionBar.NewTab ().SetText ("Activity");
tab.TabSelected += (object sender, ActionBar.TabEventArgs e) => {
if (activityFragment == null) {
activityFragment = Fragment.Instantiate (this,
Class.FromType (typeof (ActivityFragment)).Name);
activityFragment.SetHasOptionsMenu (true);
e.FragmentTransaction.Add (Android.Resource.Id.Content, activityFragment, "activity");
} else {
e.FragmentTransaction.Attach (activityFragment);
}
};
tab.TabUnselected += (object sender, Android.App.ActionBar.TabEventArgs e) => {
if (activityFragment != null)
e.FragmentTransaction.Detach (activityFragment);
};
tab.TabReselected += (object sender, ActionBar.TabEventArgs e) => {
if (activityFragment != null)
((ActivityFragment)activityFragment).Refresh ();
};
ActionBar.AddTab (tab);
}