关闭优化导航抽屉速度 - Xamarin Android

时间:2017-07-16 13:45:45

标签: c# android xamarin xamarin.android navigation-drawer

我想优化导航抽屉关闭的速度。在我的导航抽屉上,当我点击一个项目时,它导航到一个不同的活动,但导航速度不是很快(与点击导航抽屉外部时关闭的方式相比,它关闭非常顺利)。

如何在新活动出现之前使导航抽屉关闭非常顺畅?

这就是我关闭导航栏以打开新活动的方式

private void SetUpDrawerContent(NavigationView navigationView)
        {
            navigationView.NavigationItemSelected += (object sender, NavigationView.NavigationItemSelectedEventArgs e) =>
            {
                int id = e.MenuItem.ItemId;
                switch (id)
                {
                    case Resource.Id.nav_1:
                        Intent intent = new Intent(this, typeof(activity1));
                        this.StartActivity(intent);
                        GC.Collect();

                        break;

                    case Resource.Id.nav_2:
                        if (user != null)
                        {

                            Intent events = new Intent(this, typeof(EventActivity));
                            this.StartActivity(events);
                            GC.Collect();
                        }
                        else {
                            Intent loginEvent = new Intent(this, typeof(LoginActivity));
                            this.StartActivity(loginEvent);
                        }

                        break;   
                }
                e.MenuItem.SetChecked(true);
                mDrawerLayout.CloseDrawers();
            };

        }

1 个答案:

答案 0 :(得分:1)

我建议您延迟执行所选操作,直到抽屉关闭。因此,一旦用户点击导航项目,您应该记住他的选择,关闭抽屉,并且只在该过程之后选择。

相关问题