设置NavgationView的头部和菜单的方法
NavigationView navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
//获取菜单Header
View HeadView = navigationView.GetHeaderView(0);
FillNavHeadData(HeadView);
//填充头部信息
public void FillNavHeadData(View HeadView) {
ImageView nav_img_head = HeadView.FindViewById<ImageView>(Resource.Id.nav_img_head);
Users u = Globle.login_user;
if (u.image == "0") {
nav_img_head.SetImageResource(Resource.Drawable.head_1);
}else if (u.image == "1"){
nav_img_head.SetImageResource(Resource.Drawable.head_2);
}
TextView nav_lb_name = HeadView.FindViewById<TextView>(Resource.Id.nav_lb_name);
TextView nav_lb_email = HeadView.FindViewById<TextView>(Resource.Id.nav_lb_email);
nav_lb_name.Text = u.username;
nav_lb_email.Text = u.email;
}
碰到权限处理需要对NavgationView菜单的MenuItem进行隐藏。
IMenuItem m = navigationView.Menu.FindItem(Resource.Id.nav_goodsmanage);
m.SetVisible(false);
to be continue...
此贴终结,已弃坑