2017-07-16 85 views
0

我想優化導航抽屜關閉的速度。在我的導航抽屜中,當我點擊一個項目時,它導航到不同的活動,但導航速度不是很快(與點擊導航抽屜外部時如何關閉的速度相比,它關閉非常平滑)。優化導航抽屜關閉速度 - Xamarin Android

如何在新活動顯示之前使導航抽屜非常平滑地關閉?

這是我結束我的導航欄打開新的活動

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(); 
      }; 

     } 

回答

2

我建議你延遲一個選擇的動作的執行,直到抽屜被關閉。所以,一旦用戶點擊導航項目,你應該記住他的選擇,關閉抽屜,並在該過程之後才選擇。