Пример #1
0
  private void initView(Bundle savedInstanceState) {

    List<Fragment> fragments = new ArrayList<>(4);

    fragments.add(HomeFragment.newInstance(0));
    fragments.add(HomeFragment.newInstance(0));
    fragments.add(HomeFragment.newInstance(0));
    fragments.add(MeFragment.newInstance(0));

    mNavController =
        new FragNavController(
            savedInstanceState, getSupportFragmentManager(), R.id.container, fragments);

    mBottomBar = BottomBar.attach(this, savedInstanceState);
    mBottomBar.useOnlyStatusBarTopOffset();

    mBottomBar.setItems(R.menu.bottombar_menu);
    mBottomBar.setOnMenuTabClickListener(
        new OnMenuTabClickListener() {
          @Override
          public void onMenuTabSelected(@IdRes int menuItemId) {

            switch (menuItemId) {
              case R.id.bottomBarItemOne:
                mNavController.switchTab(INDEX_RECENTS);
                break;

              case R.id.bottomBarItemOne1:
                mNavController.switchTab(INDEX_FAVORITES);
                break;

              case R.id.bottomBarItemOne2:
                mNavController.switchTab(INDEX_NEARBY);
                break;

              case R.id.bottomBarItemOne3:
                mNavController.switchTab(INDEX_FRIENDS);
                break;
            }
          }

          @Override
          public void onMenuTabReSelected(@IdRes int menuItemId) {

            switch (menuItemId) {
              case R.id.bottomBarItemOne:
                Toast.makeText(NewMainActivity.this, "Home", Toast.LENGTH_SHORT).show();
                break;
              case R.id.bottomBarItemOne1:
                break;
              case R.id.bottomBarItemOne2:
                break;
              case R.id.bottomBarItemOne3:
                break;
            }
          }
        });
  }
Пример #2
0
  private void initBottomBar(Bundle savedInstanceState) {
    BottomBar mBottomBar = BottomBar.attach(this, savedInstanceState);
    mBottomBar.setItems(R.menu.main_bottom_bar);
    mBottomBar.setOnMenuTabClickListener(
        new OnMenuTabClickListener() {
          @Override
          public void onMenuTabSelected(@IdRes int menuItemId) {
            String fragmentTag = getFragmentTag(menuItemId);
            mFragment = getSupportFragmentManager().findFragmentByTag(fragmentTag);
            openScreen(fragmentTag);
          }

          @Override
          public void onMenuTabReSelected(@IdRes int menuItemId) {
            // Do nothing
          }
        });
  }