Following is my code for bottom navigation view item selected
public static void setupBottomNavigationView(BottomNavigationViewEx bottomNavigationViewEx){
Log.d(TAG, "setupBottomNavigationView: Setting up NavigationView1");
bottomNavigationViewEx.enableAnimation(false);
bottomNavigationViewEx.enableItemShiftingMode(false);
bottomNavigationViewEx.enableShiftingMode(false);
bottomNavigationViewEx.setTextVisibility(false);
}
public static void enableNavigation(final Context context, BottomNavigationViewEx view){
view.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment fragment;
switch (item.getItemId()){
case R.id.nav_home:
fragment = new FragmentMarker();
loadFragment(fragment);
return true;
case R.id.nav_bookmark:
fragment = new FragmentBookmark();
loadFragment(fragment);
return true;
case R.id.nav_blog:
fragment = new FragmentBlog();
loadFragment(fragment);
return true;
case R.id.nav_notification:
fragment = new FragmentNotification();
loadFragment(fragment);
return true;
case R.id.nav_account:
fragment = new FragmentAccount();
loadFragment(fragment);
return true;
}
return false;
}
});
}
Is there any way to display fragments on bottom navigation bar selected without re-creating activity?