BottomNavigationView with Fragments - Android Studio Tutorial
Why Stack Overflow recommends it
Stack Overflow users link it when answering or asking about setting up a bottom navigation bar that swaps fragments in Android.
Recommended by 3 people across 3 different months, 2018 to 2023.
What it is
A 16-minute Android Studio tutorial from the Coding in Flow channel showing how to add a BottomNavigationView to an activity and switch between three fragments. It uses an OnNavigationItemSelectedListener with a switch statement and replaces fragments in a FrameLayout via the support FragmentManager.
What people said
Recommends mrmeaaan · 2018-10 · Stack Overflow · on “how to make bottom app bar or bottom navigation bar like google home app?”
I think you are new to Android Studio aswell. I recommend you to watch tutorials on youtube. I searched for the one I used before which worked out for me Bottom Navigation View [this video] . It is pretty short and you get the idea quickly.
Recommends Mosericko · 2021-08 · Stack Overflow · on “Bottom Nagvigation View On click does not work”
In your question you said you didn't really know how the BotttomNavigationView works and I have provided a link here [this video] to one of the best android development tutors on YouTube that will help you understand it in-depth but for further clarity on how to do it as from the code you just provided at the top then I would suggest that you use a switch case as I used below and worked well for me as per the CodingInFlow Tutorial private final BottomNavigationView.OnNavigationItemSelectedListener navListener = item -> { Fragment selectedFragment = null; switch (item.getItemId()) { case R.id.home: selectedFragment = new HomeFragment(); break; case R.id.categories: selectedFragment = new Categorie
Recommends Samy Sylvester · 2023-03 · Stack Overflow · on “Fragment Memory Leak during FragmentTransaction Android Studio”
I managed to get rid of those awful memory leaks just by moving the instantiation of the two Fragments inside the NavigationItemSelectedListener and dropping the setFragment(fragment) method! This tutorial helped me a lot: [this video] (this guy is really talented!)
Cites Brendan Gully · 2019-01 · Stack Overflow · on “How can I retain Fragments and their data on both orientation change using BottomNavigationView”
After following a couple of Youtube tutorials (eg [this video] ) I was able to build an Activity with a BottomNavigationView, that switches between three different fragments. I'm not sure if this is the best method to achieve my goals. I need three screens, one of which (ReportFragment) will have user entered data that I wish to remaining place as the user switches between fragments. The difficulty I am having is also retaining the Fragment data on an orientation change. Here is one of the Fragment codes, I have implemented onSavedInstanceState to recall the data the user has entered and it seems to work okay: public class ReportFragment extends Fragment { EditText textCheck; EditText textCheck2;
Cites Andrey Starenky · 2019-03 · Stack Overflow · on “Cannot get Fragment to show”
Trying to create a bottom navigation bar using 3 fragments. Followed this tutorial [this video] which worked fine but I could not get it to switch from fragment to fragment. It doesn't even start with the initial fragment. As you will notice, I set up print statements to see if it actually registered the button clicks, and it prints it but does not activate the fragment package com.starenkysoftware.macapp; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.webkit.WebView; import android.we
Cites Nicolas Klarsfeld · 2019-04 · Stack Overflow · on “Packages that can be installed with gradle”
I am new to Android. As I wanted to make a bottom navigation view, I found a youtube video explaining how to do it : [this video] So he says that for the import steps, I have to : 1) add the following line in the app:build.gradle file implementation 'com.android.support:design:28.0.0' 2) add the following line in the main activity source file import android.support.design.widget.BottomNavigationView Everything works fine, however there is something I don't understand concerning the internet documentation of this class. I found the class documentation with google : [LINK] but when I follow the path from the root of the android documentation, I am stuck there : [LINK] and I don't find the class Bot
Cites NIKHIL MAURYA · 2019-12 · Stack Overflow · on “Passing data from activity "like login page" To Tabbed fragments”
[this video] I am not sure about the quality of the videos but make sure to search enough on the internet about the things you are not sure about.
Cites ZeroByter · 2020-03 · Stack Overflow · on “BottomNavigationView is empty”
I was following this tutorial [this video] for adding a BottomNavigationView to my Android Studio project. I migrated my project to AndroidX and noticed the BottomNavigationView he is using in the video might not be compatible with AndroidX, so I decided to use implementation 'com.google.android.material:material:1.1.0' instead. The problem Upon adding my BottomNavigationView and setting up all the relevant attributes, I see that it's still empty, despite following all instructions and checking that everything is correct. Notice how the BottomNavigationView is completely empty and has a height of 0 [LINK] This is my activity's XML: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:andr