登陆

如何在XamarinFormsAndroid中隐藏时禁用单击TabbedPage菜单项?

admin 2022-11-25 22人围观 ,发现0个评论

我有一个XF应用程序,TabbedPage当用户处于测验模式时隐藏菜单,并在用户停止测验模式时再次显示该菜单.以下是我隐藏和显示菜单的代码:

public static void ClearNav() {    navHomeTabPage.Icon = "";    navHomeTabPage.Title = "";    // more items }  public static void SetNav() {    navHomeTabPage.Icon = "home.png";    navHomeTabPage.Title = "Home";    // more items } 

有了这个,我可以隐藏菜单项,但它们仍然是可点击的.有没有办法在Xamarin.Android中禁用此点击事件?我找不到任何关于此的文章/帖子.任何帮助表示赞赏.

编辑:

BottomNavigationView用来将我的标签菜单放在底部.

public class BottomTabPageRenderer : TabbedPageRenderer, BottomNavigationView.IOnNavigationItemSelectedListener, BottomNavigationView.IOnNavigationItemReselectedListener {    private MainPage _page;    protected override void OnElementChanged(ElementChangedEventArgs e)    {       base.OnElementChanged(e);        if (e.NewElement != null)       {           _page = (MainPage)e.NewElement;       }       else       {           _page = (MainPage)e.OldElement;       }        // More codes    }     bool BottomNavigationView.IOnNavigationItemSelectedListener.OnNavigationItemSelected(IMenuItem item)    {       base.OnNavigationItemSelected(item);       if (App.quizRunning == true)       {           _page.CurrentPage = App.navCardsTabPage;       }          return true;    }     void BottomNavigationView.IOnNavigationItemReselectedListener.OnNavigationItemReselected(IMenuItem item)    {        if (App.quizRunning == true)       {           _page.CurrentPage = App.navCardsTabPage;       }    } 

App.navCardsTabPage具有隐藏和显示标签项标题和图标(SetNavClearNav)的代码.

请发表您的评论
请关注微信公众号
微信二维码
不容错过
Powered By Z-BlogPHP