BOTTOM NAVIGATION VIEW - Android Fundamentals

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ส.ค. 2024
  • In this video you will learn how to implement a BottomNavigationView to navigate between fragments.
    ⭐ Get certificates for your future job
    ⭐ Save countless hours of time
    ⭐ 100% money back guarantee for 30 days
    ⭐ Become a professional Android developer now:
    pl-coding.com/...
    Regular Android tutorials on my Instagram: / philipplackner_official
    Checkout my GitHub: github.com/phi...

ความคิดเห็น • 123

  • @manishpingale6558
    @manishpingale6558 3 ปีที่แล้ว +11

    Great Tutorial man !!!! I am watching your every single video in this series and I AM LOVING IT!!!!
    Thanks For Such Valuable Content
    MIllions subscribers on your way.

  • @srivastav3684
    @srivastav3684 3 ปีที่แล้ว +9

    You have a very good knowledge plus a good voice to express it. Don't stop it brother, your views are increasing day by day. If you continue like this, your channel might hit 1 lakh subscribers in the next few months. All the best

  • @brandondelacruz2933
    @brandondelacruz2933 4 ปีที่แล้ว +3

    New channel, yet the quality of this tutorial is gold

  • @valarmorghulisx
    @valarmorghulisx 4 ปีที่แล้ว +7

    You can add this implementation guys.
    implementation 'com.google.android.material:material:1.2.0-alpha05'

  • @tanloc1273
    @tanloc1273 2 ปีที่แล้ว +15

    since setOnNavigationItemSelectedListener is deprecated
    use setOnItemSelectedListener instead:
    binding.btNav.setOnItemSelectedListener {
    when(it.itemId) {
    R.id.miHome -> setCurrentFragment(firstFragment)
    R.id.miMessage -> setCurrentFragment(secondFragment)
    R.id.miProfile -> setCurrentFragment(thirdFragment)
    }
    true
    }
    Hope it can help you

    • @orbulak
      @orbulak ปีที่แล้ว

      Thanks, but do u have any solution for this? wtihout deprecation

    • @rabihutomo1598
      @rabihutomo1598 ปีที่แล้ว

      thanks man for saving my time

  • @ste1516
    @ste1516 3 ปีที่แล้ว +2

    16:43 there are nothing to improve, your explanation is perfect

  • @MCA_HimanshuSeth
    @MCA_HimanshuSeth 4 ปีที่แล้ว +1

    Very good , now I am feeling like a developer 😁😁

  • @yadude101
    @yadude101 2 ปีที่แล้ว +9

    these are all very good tutorials, I am watching each one, but these are getting somewhat confusing, could you provide an overview at the beginning so we can see how all these files and built in functions work together? You explain what each function does but if you could further explain what each function in terms of it's relation to the other functions and lists etc. in other files at each step, it would help. Keep up the the great work! and thank you. netninja provides a good level of explanation, he may be a good model to follow?

  • @chris_rb84
    @chris_rb84 4 ปีที่แล้ว +3

    You are my Hero! Thank you so much!

  • @valarmorghulisx
    @valarmorghulisx 4 ปีที่แล้ว +1

    İ finished it! great explaining! you are awesome!

  • @Prog10000
    @Prog10000 3 ปีที่แล้ว

    Thank you very much. This is the best tutorial on this subject

  • @vlc5554
    @vlc5554 2 ปีที่แล้ว

    Cool Information, it appreciate for a New Development !!!

  • @pratikthorat3480
    @pratikthorat3480 3 ปีที่แล้ว

    This right here! nothing less than divine. Thanks Philipp

  • @riteshgeddam3619
    @riteshgeddam3619 3 ปีที่แล้ว +4

    how can we change the title of action bar at top , when clicked on particular icon from the bottom menu?
    for e.g on clicking home it should display Home instead of Tutorials, same for others too.

  • @Somerandomnessvvv
    @Somerandomnessvvv 3 ปีที่แล้ว +6

    since setOnNavigationItemSelectedListener is deprecated
    use setOnItemSelectedListener instead:
    bottomNavigationView.setOnItemSelectedListener{
    when(it.itemId) {
    R.id.messages -> setCurrentFragment(fragSecond)
    R.id.profile -> setCurrentFragment(fragThird)
    else -> setCurrentFragment(fragFirst)
    }
    true
    }

    • @tushankdutt8954
      @tushankdutt8954 2 ปีที่แล้ว

      Is this method still working buddy?

    • @Somerandomnessvvv
      @Somerandomnessvvv 2 ปีที่แล้ว

      @Emprende Libre 'when' is not a method/function. It is part of Kotlin's conditional statements/expressions you can learn more about it here th-cam.com/video/dSsLy-_pPI8/w-d-xo.html
      Here I am using when as a statement to check every item id and set my fragments accordingly

  • @MMB3245
    @MMB3245 3 ปีที่แล้ว +5

    Hi Philipp, this is such a wonderful video. In the beginning of the video (0:16) you mentioned 'it should have at least 3 fragments.' Is there any particular reason for this?
    I've tested using two fragments and it seems to work fine so far. Any comment on this issue if you may?

    • @alejandroflorez9409
      @alejandroflorez9409 2 ปีที่แล้ว +3

      I think it's a convention of the Material Design Standard, not about a technical reason.

  • @aav42005
    @aav42005 3 ปีที่แล้ว

    Thank you for a very detailed tutorial.

  • @wowovanmbothen
    @wowovanmbothen 4 ปีที่แล้ว +3

    Thanks for the explanation..
    Btw i have a question
    If i want to get the data from another activity and i want use that data on my fragments (first fragment and second fragmen), should i use intent on each fragments or only use intent on the activity??

  • @sheffomp
    @sheffomp 4 ปีที่แล้ว +1

    Good bonus ! Great Videos so far!

  • @LaurinusPonpon
    @LaurinusPonpon 3 ปีที่แล้ว

    Thanks sooooo much. So clear!

  • @josephgellida
    @josephgellida 2 ปีที่แล้ว +2

    the code is little bit deprecated i cant reach the change between fragments.

  • @android-dev
    @android-dev ปีที่แล้ว +1

    Could you make a video how to save fragments state when switching between them with bottom navigation bar (using xml and navigation component). It would be really helpful for beginners. Thank you!

    • @knflux9840
      @knflux9840 ปีที่แล้ว

      You are probably gonna want to use a ViewModel for that, I think he has some videos on that.

  • @bigotes20random86
    @bigotes20random86 2 ปีที่แล้ว

    Thank you so much mate!! :D

  • @kareemkamal6185
    @kareemkamal6185 3 ปีที่แล้ว

    great Tutorial man !!!

  • @sasidharan1937
    @sasidharan1937 3 ปีที่แล้ว

    Speechless !!!

  • @DanielMaze-tr1kp
    @DanielMaze-tr1kp ปีที่แล้ว

    After i create the botton button view can i just create buttons on a created fragment and everything will show or is there another step? Im trying to create a sple menue on one of the fragments with a button

  • @srini01
    @srini01 3 ปีที่แล้ว +1

    You have recorded this video in Mar. But by now the dependencies in build.gradle file could have have been updated. From where do i get the latest dependencies. if you use the dependencies you mentioned it is showing error

    • @thekralj9600
      @thekralj9600 3 ปีที่แล้ว

      you can just hit alt+enter and it'll find the latest version

  • @bessamlegrand
    @bessamlegrand 3 ปีที่แล้ว

    Wunderbar tutorial meine freund, ich liebe dich

  • @tomasyedid3140
    @tomasyedid3140 3 ปีที่แล้ว

    Thank for the video, it helps me a lot! I have one question, i did the same as you but at the time of running the App, each time i touch an item, gets double in the screen. I start in home but when a touch another item, goes to that fragment and the homeFragment stills there. any help?

  • @hanadanefa7837
    @hanadanefa7837 4 ปีที่แล้ว

    Thanks it works perfectly hahaha, i just miss the commit line sorry for that

  • @zerotechighqualitytutorial568
    @zerotechighqualitytutorial568 2 ปีที่แล้ว

    könntest du das nicht auch alles auf deutsch machen :D sehr hilfreiches video danke dafür

  • @brucebane7401
    @brucebane7401 3 ปีที่แล้ว

    really informative !!!!!

  • @NeitonSilva
    @NeitonSilva 4 ปีที่แล้ว

    Great video!

  • @bugra1994
    @bugra1994 4 ปีที่แล้ว +1

    Great video! I wonder is there any chance you can upload these mini projects on GitHub so that we can copy/paste some parts?

    • @PhilippLackner
      @PhilippLackner  4 ปีที่แล้ว +2

      Thank you for the feedback! That's a good point, but sadly I don't have all the projects anymore. I think I will start with this in my next series from the beginning on

    • @bugra1994
      @bugra1994 4 ปีที่แล้ว +1

      @@PhilippLackner that would be great, thank you :)

  • @princedeka6054
    @princedeka6054 3 ปีที่แล้ว

    New subscriber 😎👍

  • @TheImaginativeSachin
    @TheImaginativeSachin ปีที่แล้ว

    Hey In the fragments we added (addToBackStack) to remember the stack of fragment. I want to also synchronize the bottom navigation items with those stack. When clicking the back button only the fragment's stack is used.
    Is there anyway to also remember the stack of bottom navigation synchronized with the fragments while using back button?
    If you have answer please comments friends!!

  • @urvishbundela7826
    @urvishbundela7826 3 ปีที่แล้ว

    This was awesome, but I wonder, can I use three separate activities in place of those three fragments. is that possible ? and is it easy to do so ?

  • @Self_growth_and_Love
    @Self_growth_and_Love 3 ปีที่แล้ว

    What if I want to set the counter based on the amount of nodes that get added to my firebase Database? Or when I add a layout to my recycler view adapter? Basically making the counter Dynamic.

  • @manshalkhatri9289
    @manshalkhatri9289 ปีที่แล้ว

    Helpful

  • @Marinakulichok
    @Marinakulichok 4 ปีที่แล้ว +1

    Still can not understand diff between vector and image assets.

  • @savannasullivan4443
    @savannasullivan4443 3 ปีที่แล้ว

    Really useful tutorial but do you have the same tutorial for Java instead of Kotlin? Thanks

    • @rowenarrow
      @rowenarrow 2 ปีที่แล้ว +2

      I was faced with this same question and decided to scrap working with Java and move onto Kotlin. I watched is Kotlin playlist and am now here on this playlist. While I took my time to get here I am happy I did and ready to move forward using Kotlin. I would suggest anyone who is at is using Java to do the same.

  • @AN-im4yp
    @AN-im4yp 3 ปีที่แล้ว

    I have error on bottomnavigationview.setOnItemSelectedListener in main activity why?

  • @geraldlinao1143
    @geraldlinao1143 3 ปีที่แล้ว

    Philipp are you using kotlin x is it still working kotlin x is deprecated now

  • @rowenarrow
    @rowenarrow 2 ปีที่แล้ว +2

    As of Jul 2022 I had to use binding.bottomNavigationView.setOnItemSelectedListener {} to get this to work. Hope this helps!

  • @nt1231
    @nt1231 2 ปีที่แล้ว

    i Just want to add back stack in every fragments how i can ? i mean addToBackStack(null)

  • @programmer4047
    @programmer4047 3 ปีที่แล้ว

    Hey!
    You forgot to paste the dependency in the description box

  • @harshaharshi7269
    @harshaharshi7269 4 ปีที่แล้ว

    sir how to get the dependencies like for bottom navigation bar you have a dependency where will we get those dependency

  • @Anonymous-nx9fh
    @Anonymous-nx9fh 3 ปีที่แล้ว

    How can I add a coloured line below the selected item in bottom nav ?

  • @shreyashchoudhary7413
    @shreyashchoudhary7413 3 ปีที่แล้ว

    EPIC!

  • @yisun9573
    @yisun9573 ปีที่แล้ว

    setOnNavigationItemSelectedListener is deprecated, we need to use onNavigationItemSelected

  • @AryanvedhFromIndia
    @AryanvedhFromIndia 3 ปีที่แล้ว

    implementation isnt working. showing error, has it changed since you made the video?

  • @mohitmahajan1947
    @mohitmahajan1947 4 ปีที่แล้ว +6

    why don't you use jetpack navigation?

    • @LaBoots
      @LaBoots ปีที่แล้ว

      Because it’s cheeks

    • @mohitmahajan1947
      @mohitmahajan1947 ปีที่แล้ว +1

      @@LaBoots i changed my domain lol

  • @md.imranhossain5364
    @md.imranhossain5364 3 ปีที่แล้ว

    How can I move everything from main activity to Home Fragment ?

  • @roerbakeitje1
    @roerbakeitje1 4 ปีที่แล้ว

    Realy sorry i.m a beginner. And need help. Fragment 1 must be a webview . Must i make this is in mainactivity or in fragment 1 .XML. all the tutrorials begin with a new app. Sorry i want to understand it.

    • @PhilippLackner
      @PhilippLackner  4 ปีที่แล้ว +1

      I don't really get you, but if you ask where you should put the webview, then in the fragment XML if you want it to be displayed in the fragment

    • @roerbakeitje1
      @roerbakeitje1 4 ปีที่แล้ว

      @@PhilippLackner so if i get it now. i must first make a splash screen . Than the menu with fragments and within the fragments i must made the other stuff.

  • @bharathkrishnan23
    @bharathkrishnan23 3 ปีที่แล้ว

    How can we test bottom navigation using espresso

  • @loveshpurswani632
    @loveshpurswani632 3 ปีที่แล้ว

    I don't know but the bottomNavigationView.setOnNavigationItemSelectedListener() is not working for me. it's not even coming in the auto completion. if anybody could help.

    • @edenlu1331
      @edenlu1331 3 ปีที่แล้ว

      replace with setOnItemSelectedListener

  • @beeatechjs2928
    @beeatechjs2928 2 ปีที่แล้ว

    good

  • @MCA_HimanshuSeth
    @MCA_HimanshuSeth 4 ปีที่แล้ว

    Dear sir I got an error when I implemented the dependency
    com.google.android.matetial: material:1.2.0-alpha04. The error is that - DSL method not found implementation ()

    • @rufansdev7446
      @rufansdev7446 3 ปีที่แล้ว

      implementation 'com.google.android.material:material:1.2.0-alpha04'

  • @lara-kp7lp
    @lara-kp7lp 4 ปีที่แล้ว

    How we can add recyclerview in fragment?

  • @hari7027
    @hari7027 3 ปีที่แล้ว

    Bro i have downloaded icons but when i am adding them they are not showing up instead empty square is showing up what to do

    • @erezlevanon469
      @erezlevanon469 ปีที่แล้ว

      notice that you have icon_name_foreground and same with background, use the foreground and not the background when selecting the icon to attach

  • @htgsniper8458
    @htgsniper8458 ปีที่แล้ว

    **********Pls help bro *******************
    Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
    This is the error I'm getting while doing the projects what can I do to resolve this error i cant find any answer in stack overflow and any other sources, also tell us where can we get solutions if i get errors ?

  • @kamyt3460
    @kamyt3460 2 หลายเดือนก่อน

    where is dependecies?

  • @un7sh226
    @un7sh226 ปีที่แล้ว

    Is anyone having the problem where the XML preview disappears just like in the Fragment video when we dont mention the tools:layout = "@layout/first_fragment" line in the fragment tags? if so does anyone know how to fix this problem?

    • @un7sh226
      @un7sh226 ปีที่แล้ว +1

      i fixed by downgrading the material version from 1.5.0 to 1.4.0

    • @ishaangupta6915
      @ishaangupta6915 ปีที่แล้ว

      u need to click on the ! icon, then again a popup from bottom will appear, then again it will show the ! icon on the bottom pain, click on it, anothe popup will appear to the right with 2 li ks highlighted in blue, click on the second one

  • @Yash-jp6xh
    @Yash-jp6xh 3 ปีที่แล้ว

    I wanted this video with java

  • @hanadanefa7837
    @hanadanefa7837 4 ปีที่แล้ว

    how can we change the name of the toolbar? everytime the bottom navigation is clicked?

    • @PhilippLackner
      @PhilippLackner  4 ปีที่แล้ว

      You mean the title?

    • @hanadanefa7837
      @hanadanefa7837 4 ปีที่แล้ว

      @@PhilippLackner I think it is

    • @hanadanefa7837
      @hanadanefa7837 4 ปีที่แล้ว

      Clicked from bottom nav

    • @wowovanmbothen
      @wowovanmbothen 4 ปีที่แล้ว

      Maybe using ActionBar..
      Set the ActionBar name with the title name (for this example home/ messages/ profile).. cmiiw

  • @rihanarinsi9988
    @rihanarinsi9988 ปีที่แล้ว

    in my values folder, there is no styles.xml file ..

    • @abhisheh2191
      @abhisheh2191 8 หลายเดือนก่อน

      now its themes>themes.xml

  • @jackwinter2669
    @jackwinter2669 2 ปีที่แล้ว +1

    everything works up until 15:00

    • @jackwinter2669
      @jackwinter2669 2 ปีที่แล้ว +1

      bottomNavigationView is unknown

    • @sujalaggrawal5481
      @sujalaggrawal5481 11 หลายเดือนก่อน

      /Code/
      package com.example.bottomnavigation
      import androidx.appcompat.app.AppCompatActivity
      import android.os.Bundle
      import android.util.Log
      import android.widget.Button
      import androidx.fragment.app.Fragment
      import com.google.android.material.bottomnavigation.BottomNavigationView
      class MainActivity : AppCompatActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      lateinit var bottomNav : BottomNavigationView
      var firstFragment = FirstFragment()
      var secondFragment = SecondFragment()
      var thirdFragment = ThirdFragment()
      setCurrentFragment(firstFragment)
      bottomNav = findViewById(R.id.bottomNavigationView)
      bottomNav.setOnItemSelectedListener {
      when (it.itemId) {
      R.id.miHome -> setCurrentFragment(firstFragment)
      R.id.miMessages -> setCurrentFragment(secondFragment)
      R.id.miProfile -> setCurrentFragment(thirdFragment)
      }
      true
      }
      bottomNav.getOrCreateBadge(R.id.miMessages).number=10
      }
      private fun setCurrentFragment(fragment: Fragment)=
      supportFragmentManager.beginTransaction().apply {
      replace(R.id.flFragment, fragment)
      commit()
      }
      }

  • @hanadanefa7837
    @hanadanefa7837 4 ปีที่แล้ว

    sorry i forgot to put the commit lol

  • @sahilmakkar2354
    @sahilmakkar2354 3 ปีที่แล้ว +1

    Getting error
    'setOnNavigationItemSelectedListener(BottomNavigationView.OnNavigationItemSelectedListener?): Unit' is deprecated. Deprecated in Java

    • @edenlu1331
      @edenlu1331 3 ปีที่แล้ว +3

      replace it with setOnItemReselectedListener

    • @edenlu1331
      @edenlu1331 3 ปีที่แล้ว +2

      *meant setOnItemSelectedListener

    • @carelventer1964
      @carelventer1964 3 ปีที่แล้ว

      @@edenlu1331 Thank you

  • @GrumpyOldMan9
    @GrumpyOldMan9 3 ปีที่แล้ว

    Surely, there must be a simpler way.

  • @hanadanefa7837
    @hanadanefa7837 4 ปีที่แล้ว

    how can we add buttons in here?

    • @PhilippLackner
      @PhilippLackner  4 ปีที่แล้ว

      Where do you want to add them?

    • @hanadanefa7837
      @hanadanefa7837 4 ปีที่แล้ว

      @@PhilippLackner in the fragment itself, i have a problem that encounter, the textview do not appear even that i follow your instruction, what could be the problem, i am using the latest android studio

    • @hanadanefa7837
      @hanadanefa7837 4 ปีที่แล้ว

      @@PhilippLackner not just button but also something like recyclerviewer,

  • @alfian3570
    @alfian3570 3 ปีที่แล้ว

    up

  • @ksalarang
    @ksalarang 2 ปีที่แล้ว

    A comment for promotion.

  • @thijsj2128
    @thijsj2128 ปีที่แล้ว

    Doesn't work. Don't bother

  • @ramadhansaputra3812
    @ramadhansaputra3812 ปีที่แล้ว

    getorcreatebadge

  • @yisun9573
    @yisun9573 ปีที่แล้ว

    I find that addToBackStack can add fragment to the stack. So, is there any listener which can let me know the stack is pop out? Because I want set some status of the fragment.
    Or there will be some other functions?
    binding!!.btnFragment1.setOnClickListener{
    if(state != 0){
    supportFragmentManager.beginTransaction().apply {
    replace(R.id.flFragment, firstFragment)
    addToBackStack("0")
    commit()
    }
    }
    state = 0
    }