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 …

Nguồn:https://u-os.org/

Author

22 Comments

  1. Coding in Flow Reply

    DEPENDENCY UPDATE:
    If your project is using AndroidX dependencies, add this new dependency instead of the design support library: implementation 'com.google.android.material:material:1.1.0'
    ________________________________
    If you want to keep the selected fragment when rotating the device, make the following little change to the code:

    Surround the fragment transaction in the onCreate method with an if/else statement like this (I also changed the code on my website):

    if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
    new HomeFragment()).commit();
    }

  2. 주주jujutham Reply

    Sir, could you please explain how to add buttons on viewmodel class?

  3. Blue Kaioken Reply

    Great Video!!!, very good guiding, explaining and showing, I have a question, do you know how to prevent fragments to refresh on tab changing ? I haven't seen a good tutorial for it, whatever I find online does not work or doesn't explain thoroughly. Thanks in advance.

  4. Frederyk Linhares Reply

    Wow! Straightforward to the point! Congratulations! Very very good tutorial!

  5. Thamizhan Thiru Reply

    Dependencies
    Error:Failed to resolve:androidx.appcompat:design:1.1.0

    Please Hlp me Sir…!!!!

  6. Martín Pe'C Reply

    Hi, thanks a lot, really helped

    I just have a question, how can you override the pending transition between the fragments?… I've tried the usual instruction but it doesn't work. Thanks again.

  7. sushmitha prasana Reply

    hi really super your explaination… i quickly grasp your class.. and your voice is super and nice to hear…thank u

  8. Jay Khandelwal Reply

    The following classes could not be instantiated:

    – com.google.android.material.bottomnavigation.BottomNavigationView

  9. Róbert Katona Reply

    i am new to android development and this tutorial was super helpful!
    thank you!

  10. Sport fitness Reply

    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

  11. Ana Aguilar Reply

    is there an easy way to figure out what in the world we have to implement depending on the version we are using? I don't know why I am having problems with this, I can't find a simple straight up answer on google or developer.android.com seems like the answer should be clear. I have tried so many implementations and they are wrong.

  12. Venkatesh Chowdary Reply

    I used your code in my project like how you done. But the problem is when I start clicking from 4th tab to any other tab anonymously the bottom navigation bar gets pushed down.

Write A Comment