[英]How to manage navigation drawer button?
I want to do this: when I press to button: 我想这样做:当我按下按钮时:
I want do this: if user (Parse user) has done login, it must show the navigation drawer. 我想这样做:如果用户(Parse用户)已完成登录,则必须显示导航抽屉。 If user isn't logged on, I want to open LoginActivity.java.
如果用户未登录,我想打开LoginActivity.java。 I do this:
我这样做:
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
{
public void onDrawerOpened(View view)
{
if(currentUser == null) //utente non loggato
{
Intent intent = new Intent(MenuActivity.this,LoginActivity.class);
startActivity(intent);
currentUser = ParseUser.getCurrentUser();
}
else
{
super.onDrawerOpened(view);
}
}
public void onDrawerClosed(View v)
{
super.onDrawerClosed(v);
}
};
but it opens also navigation drawer (and I want that opens directly LoginActivity.java). 但它也打开导航抽屉(我希望它直接打开LoginActivity.java)。 So I try it:
所以我试试看:
toggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
if(currentUser == null) //utente non loggato
{
Intent intent = new Intent(MenuActivity.this,LoginActivity.class);
startActivity(intent);
currentUser = ParseUser.getCurrentUser();
}
}
});
but it doesn't work. 但它不起作用。 So what I have to do?
那我该怎么办? Thanks
谢谢
Disable the Navigation Drawer by setDrawerIndicatorEnabled(false);
通过
setDrawerIndicatorEnabled(false);
禁用导航抽屉setDrawerIndicatorEnabled(false);
and re-enable ( setDrawerIndicatorEnabled(true);
) it once the user is successfully logged in. 并在用户成功登录后重新启用 (
setDrawerIndicatorEnabled(true);
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.