【发布时间】:2018-05-16 15:47:32
【问题描述】:
我已经在我的 c# Android 应用程序中实现了一个导航抽屉,我在github 中做了与这个项目相同的操作。问题是导航只显示在一个活动中,然后如果我尝试从导航启动另一个活动,它就会消失。我希望在 Activity 启动后,Navigation Drawer 能够像 ASP.NET 中 MasterPage 中的情况一样保持不变而不会消失。 这就是我试图做的,以便在我的第二个活动中显示抽屉,该活动是在导航抽屉项目点击上启动的:
public class SecondActivity: NavActivity // extending from the NavActivity where the Navigation drawer is implemented
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
View contentView = inflater.Inflate(Resource.Layout.portfolio_layout, null, false);
drawerLayout.AddView(contentView, 0);
Toast.MakeText(this, "Home selected!", ToastLength.Short).Show();
}
}
但是SecondActivity 代码编译成功我知道这是因为Toast message 正在显示。
【问题讨论】:
标签: c# android visual-studio xamarin navigation