BOTTOM NAVIGATION VIEW - Android Fundamentals

Поделиться
HTML-код
  • Опубликовано: 8 мар 2020
  • 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/premium-courses...
    Regular Android tutorials on my Instagram: / philipplackner_official
    Checkout my GitHub: github.com/philipplackner

Комментарии • 123

  • @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

  • @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.

  • @Prog10000
    @Prog10000 3 года назад

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

  • @aav42005
    @aav42005 3 года назад

    Thank you for a very detailed tutorial.

  • @valarmorghulisx
    @valarmorghulisx 4 года назад +7

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

  • @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 ruclips.net/video/dSsLy-_pPI8/видео.html
      Here I am using when as a statement to check every item id and set my fragments accordingly

  • @MCA_HimanshuSeth
    @MCA_HimanshuSeth 4 года назад +1

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

  • @pratikthorat3480
    @pratikthorat3480 3 года назад

    This right here! nothing less than divine. Thanks Philipp

  • @brandondelacruz2933
    @brandondelacruz2933 4 года назад +3

    New channel, yet the quality of this tutorial is gold

  • @vlc5554
    @vlc5554 2 года назад

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

  • @LaurinusPonpon
    @LaurinusPonpon 3 года назад

    Thanks sooooo much. So clear!

  • @valarmorghulisx
    @valarmorghulisx 4 года назад +1

    İ finished it! great explaining! you are awesome!

  • @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

  • @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??

  • @ste1516
    @ste1516 3 года назад +2

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

  • @chris_rb84
    @chris_rb84 4 года назад +3

    You are my Hero! Thank you so much!

  • @bigotes20random86
    @bigotes20random86 2 года назад

    Thank you so much mate!! :D

  • @kareemkamal6185
    @kareemkamal6185 3 года назад

    great Tutorial man !!!

  • @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?

  • @sasidharan1937
    @sasidharan1937 3 года назад

    Speechless !!!

  • @NeitonSilva
    @NeitonSilva 4 года назад

    Great video!

  • @sheffomp
    @sheffomp 4 года назад +1

    Good bonus ! Great Videos so far!

  • @brucebane7401
    @brucebane7401 3 года назад

    really informative !!!!!

  • @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.

  • @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.

  • @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?

  • @princedeka6054
    @princedeka6054 3 года назад

    New subscriber 😎👍

  • @manshalkhatri9289
    @manshalkhatri9289 Год назад

    Helpful

  • @hanadanefa7837
    @hanadanefa7837 4 года назад

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

  • @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.

  • @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!!

  • @shreyashchoudhary7413
    @shreyashchoudhary7413 3 года назад

    EPIC!

  • @DanielMaze-tr1kp
    @DanielMaze-tr1kp 11 месяцев назад

    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

  • @zerotechighqualitytutorial568
    @zerotechighqualitytutorial568 2 года назад

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

  • @Anonymous-nx9fh
    @Anonymous-nx9fh 3 года назад

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

  • @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.

  • @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 :)

  • @nt1231
    @nt1231 2 года назад

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

  • @beeatechjs2928
    @beeatechjs2928 2 года назад

    good

  • @lara-kp7lp
    @lara-kp7lp 3 года назад

    How we can add recyclerview in fragment?

  • @programmer4047
    @programmer4047 3 года назад

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

  • @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 ?

  • @md.imranhossain5364
    @md.imranhossain5364 3 года назад

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

  • @AN-im4yp
    @AN-im4yp 3 года назад

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

  • @bharathkrishnan23
    @bharathkrishnan23 3 года назад

    How can we test bottom navigation using espresso

  • @geraldlinao1143
    @geraldlinao1143 3 года назад

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

  • @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.

  • @Yash-jp6xh
    @Yash-jp6xh 3 года назад

    I wanted this video with java

  • @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

  • @harshaharshi7269
    @harshaharshi7269 4 года назад

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

  • @yisun9573
    @yisun9573 Год назад

    setOnNavigationItemSelectedListener is deprecated, we need to use onNavigationItemSelected

  • @Marinakulichok
    @Marinakulichok 3 года назад +1

    Still can not understand diff between vector and image assets.

  • @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'

  • @AryanvedhFromIndia
    @AryanvedhFromIndia 3 года назад

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

  • @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

  • @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

  • @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

  • @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.

  • @GrumpyOldMan9
    @GrumpyOldMan9 2 года назад

    Surely, there must be a simpler way.

  • @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 ?

  • @rihanarinsi9988
    @rihanarinsi9988 Год назад

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

    • @abhisheh2191
      @abhisheh2191 7 месяцев назад

      now its themes>themes.xml

  • @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

  • @kamyt3460
    @kamyt3460 Месяц назад

    where is dependecies?

  • @mohitmahajan1947
    @mohitmahajan1947 4 года назад +6

    why don't you use jetpack navigation?

  • @hanadanefa7837
    @hanadanefa7837 4 года назад

    sorry i forgot to put the commit lol

  • @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,

  • @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()
      }
      }

  • @alfian3570
    @alfian3570 3 года назад

    up

  • @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 2 года назад

      @@edenlu1331 Thank you

  • @ksalarang
    @ksalarang 2 года назад

    A comment for promotion.

  • @ramadhansaputra3812
    @ramadhansaputra3812 Год назад

    getorcreatebadge

  • @thijsj2128
    @thijsj2128 Год назад

    Doesn't work. Don't bother

  • @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
    }

  • @rowenarrow
    @rowenarrow 2 года назад +2

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