当前位置: 首页>>代码示例>>C#>>正文


C# Fragment.SetHasOptionsMenu方法代码示例

本文整理汇总了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);
        }
开发者ID:Andrea,项目名称:FriendTab,代码行数:71,代码来源:MainActivity.cs


注:本文中的Fragment.SetHasOptionsMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。