我想在内部显示 Bottom Navigation View 片段,就像Instagram一样。首先是否可以在片段内添加底部导航视图?如果是,那又如何?
这是在onCreateView内:
private BottomNavigationView.OnNavigationItemSelectedListener
mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
Fragment fragment;
switch (menuItem.getItemId()){
case R.id.navigation_home:
toolbar.setTitle("Home");
return true;
case R.id.navigation_attend:
toolbar.setTitle("Attendance");
return true;
case R.id.navigation_inquire:
toolbar.setTitle("Inquiry");
return true;
case R.id.navigation_help:
toolbar.setTitle("Help Desk");
return true;
case R.id.navigation_setting:
toolbar.setTitle("Profile");
return true;
}
return false;
}
};
根据https://www.androidhive.info/2017/12/android-working-with-bottom-navigation/,我们必须使用:
ActionBar toolbar = getSupportActionBar();
toolbar.setTitle("Home");
但是我知道这不起作用... 预先感谢