我有以下实现侧面菜单实现。在该实现中,它需要ActionBar
。
但我想禁用ActionBar
并添加ImageButton
,这样就可以让用户打开或关闭侧边菜单。我怎么能这样做?
mDrawerToggle = new ActionBarDrawerToggle (this, mDrawerLayout, Resource.Drawable.icon, Resource.String.open_drawer, Resource.String.close_drawer);
protected override void OnPostCreate (Bundle savedInstanceState)
{
base.OnPostCreate (savedInstanceState);
mDrawerToggle.SyncState ();
}
public override bool OnOptionsItemSelected (IMenuItem item)
{
if (mDrawerToggle.OnOptionsItemSelected (item)) {
return true;
}
return base.OnOptionsItemSelected (item);
}
答案 0 :(得分:-1)
以下是答案:
mDrawerButton = FindViewById<ImageButton> (Resource.Id.sidemenubutton);
mDrawerButton.Click += delegate {
if(!mDrawerLayout.IsDrawerOpen(GravityCompat.Start)) {
mDrawerLayout.OpenDrawer(GravityCompat.Start);
} else {
mDrawerLayout.CloseDrawer(GravityCompat.Start);
}
};