Switch activity/fragment with bottom navigation

fragment 're created on bottom navigation view item selected
android bottom navigation save fragment state
android bottom navigation fragment backstack
hide bottom navigation bar in fragment
bottom navigation bar androidhive
navigation drawer with bottom navigation android example
custom bottom navigation view android example
bottom navigation drawer android

I created an activity with a bottom navigation bar. I googled a lot things about it but now I don't know how to handle this exactly. Before, I just started another activity when the user clicks the bottom navigation but I think it's not good.

How can I switch between the tabs? Do I have to work with fragments? And what about 'setContentView(int layoutResID)'? How can I do that? I'm confused...

private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {

    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.navigation_home:
                return true;
            case R.id.navigation_dashboard:
                return true;
            case R.id.navigation_notifications:
                return true;
        return false;


Thank you very much for your help - I hope, you understood what I mean.

Activity transition is always expensive and we should switch from one activity to another only when we are switching the context. A fragment is a portion of UI in an activity. Same fragment can be used with multiple activities. Just like activity a fragment has its own lifecycle and setContentView(int layoutResID) can be set to different layout in OnCreate of fragment.

This link explains more on when to use activity or fragment.

Android developer guide on Fragments

Code path tutorial on bottom navigation views.

Bottom Navigation View With Fragments (No fragment re-creation)., Bottom Navigation Activity (Android studio). After a successful build, i created 3 new fragments. Home Fragment (Inflated a recycler view in it)  In this video you will learn, how to add a bottom navigation to your activity and use it to switch between different fragments. We will fill our BottomNavigationView with 3 menu items and then

Please refer to :-


and complete explanation in


You will get a running code with the explanation here.

BottomNavigationView with Fragments, An example of how to use Android's new Bottom Navigation View component to switch between separate activities. bottomnavigationview android activities. Star​  Bottom Navigation Bar is one of them. Bottom Navigation Bar always stays at the bottom of your application and provides navigation between the views of your application. So in this Bottom Navigation Android Example, we will see how we combine the Bottom Navigation and Fragments.

Bottom Navigation View is a navigation bar introduced in android library to make it easy to switch between views with a single tap. It can although be used for almost any purpose, but is most commonly used to switch between fragments with a single tap. Its use for opening activities is somewhat absurd, since it ignores its most important functionality of switching the views with a single tap. There are many good articles and blogs out there in this regard, one of which is: https://medium.com/@hitherejoe/exploring-the-android-design-support-library-bottom-navigation-drawer-548de699e8e0 Hope this solves your doubt..

Android Bottom Navigation View Tutorial using Fragments, Android design supports library that provides a Bottom Navigation Bar In this case we have 3 menu items, so you can change the default  A Fragment is a piece of an activity which enable more modular activity design. Its can be said to be a sub-activity. Multiple fragments can be used in a single activity, each fragment has it own…

                (new BottomNavigationView.OnNavigationItemSelectedListener() {
                    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                        Fragment selectedFragment = null;
                        switch (item.getItemId()) {
                            case R.id.action_item1:
                                selectedFragment = ItemOneFragment.newInstance();
                                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                                transaction.replace(R.id.frame_layout, selectedFragment);
                                // selectedFragment.getChildFragmentManager().beginTransaction();

                            case R.id.action_item2:
                                selectedFragment = ItemTwoFragment.newInstance();
                                FragmentTransaction transactiona = getSupportFragmentManager().beginTransaction();
                                transactiona.replace(R.id.frame_layout, selectedFragment);
                              //  selectedFragment = ItemThreeFragment.newInstance();

                            case R.id.action_item3:
                            //  selectedFragment = ItemOneFragment.newInstance();
                                Intent intent=new Intent(MainView.this, YoutActivityLive.class);
                               // selectedFragment = ItemTwoFragment.newInstance();

                            case R.id.action_item5:
                                selectedFragment = ItemOneFragment.newInstance();
                                FragmentTransaction transactionb = getSupportFragmentManager().beginTransaction();
                                transactionb.replace(R.id.frame_layout, selectedFragment);
                               // selectedFragment = ItemFiveFragment.newInstance();

                        return true;

ddekanski/BottomNavigationViewBetweenActivities: An , But now, a lot of Android apps have started adapting this. To name a few, the YouTube app recently made the switch. Bottom Navigation was  With Activity, you have to declare and init that BottomBar each time you load that activity. With your problem, my answer is NO. Btw, you can use Fragment which helps you solve this pretty good. Time to learn something new, bro. EDIT. You bring Fragment inside only 1 Activity. And let BottomBar inside Activity while all others view and data set

Android bottom navigation menu example using activities, Bottom navigation provide easy navigation for switching between 3 to 5 different views. It was recently added to the Material Design spec, which provides an  According to the guidelines for Material Design. On Android, the Back button does not navigate between bottom navigation bar views. EDIT: Material Design link no longer mentions back button behavior.

Bottom Navigation Android Example using Fragments, Read the material design style navigation drawer document for specs on Each item when clicked will switch the relevant fragment into the activity's container view. Dark" android:orientation="vertical" android:gravity="bottom"> <TextView​  I created an activity with a bottom navigation bar. I want tablayout when I want to switch to another fragment. And tablayout can control viewpager. Can I put viewpager to the specified fragment? I wanna like this: This is the current result. I want to put viewpager in the red box.

Bottom Navigation Bar with Fragments - Android Tutorial, This will help you to create Bottom Navigation View with fragments in your android app Subscribe : https://www.youtube.com/appeteriatechnologies Facebook : h