不能在同一活动中使用NavigationView和BottomNavigationView

时间:2019-04-04 19:24:20

标签: java android bottomnavigationview navigationview

我不能在同一活动中使用BottomNavigationViewNavigationView。当我使用NavigationView时,BottomNavigationView点击监听器不起作用,但是BottomNavigationView点击监听器起作用。 BottomNavigationView以某种方式阻止了NavigationView的点击监听器。寻求帮助

bottomnavid.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
  @Override
  public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
    if(menuItem.getItemId()==R.id.homeid)
    {
      Toast.makeText(getApplicationContext(),"home",Toast.LENGTH_LONG).show();
    }
    return false;
  }
});
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
  @Override
  public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
    if(menuItem.getItemId()==R.id.ilkYanMenuItemid)
    {
        Toast.makeText(getApplicationContext(),"ilk yan",Toast.LENGTH_LONG).show();
    }
    return false;
  }
});

0 个答案:

没有答案