【问题标题】:Navigation Drawer back button Xamarin导航抽屉后退按钮 Xamarin
【发布时间】:2016-04-22 05:54:38
【问题描述】:

我正在将此绑定用于 MikePenz 的这个很棒的 Material Drawer Library。

我已经用这个库实现了导航抽屉,当我深入时,我还设法将汉堡菜单更改为后退箭头。现在我有一些问题要让后退箭头正常工作。当我单击后退箭头时,而不是返回上一页,它会打开导航抽屉。

查看原始库后,我确定,以下代码负责管理后退箭头按钮。如果有人可以帮助我用 C# 编写此侦听器代码,我将不胜感激。

.withOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() {
                @Override
                public boolean onNavigationClickListener(View clickedView) {
                    //this method is only called if the Arrow icon is shown. The hamburger is automatically managed by the MaterialDrawer
                    //if the back arrow is shown. close the activity
                    AdvancedActivity.this.finish();
                    //return true if we have consumed the event
                    return true;
                }
            })

这是我使用的绑定库:MaterialDrawer-Xamarin

这是原始库的链接:MaterialDrawer

【问题讨论】:

    标签: xamarin xamarin.android materialdrawer


    【解决方案1】:

    试试这样的:

    var result = new DrawerBuilder()
            .WithActivity(this)
            .AddDrawerItems(
              //Add some items here
              new DividerDrawerItem()
            )
            .WithOnDrawerNavigationListener(this);
    

    并像这样在您的活动中实现Drawer.IOnDrawerNavigationListener

    public bool OnNavigationClickListener(View clickedView)
    {
        this.Finish();
        return true;
    }
    

    【讨论】:

    • 我收到此错误。当我尝试你的代码时。错误 CS1502:“Mikepenz.MaterialDrawer.DrawerBuilder.WithOnDrawerNavigationListener(Mikepenz.MaterialDrawer.Drawer.IOnDrawerNavigationListener)”的最佳重载方法匹配有一些无效参数 (CS1502)
    • 我的道歉,这行得通。只是我忘了继承接口
    猜你喜欢
    • 2015-04-11
    • 2020-12-20
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多