Navigation Component - Android Studio Tutorial

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024
  • 🏆 My Online Courses
    ⭐Discount Coupon: LAUNCH-STEVDZA-SAN
    stevdza-san.com
    🐱‍👤 Wanna become a member? Join!
    / @stevdzasan
    📸 Instagram
    / stevdza_san
    Navigation refers to the interactions that allow users to navigate across, into, and back out from the different pieces of content within your app. Android Jetpack's Navigation component helps you implement navigation, from simple button clicks to more complex patterns, such as app bars and the navigation drawer.
    The Navigation component consists of three key parts that are described below:
    Navigation graph: An XML resource that contains all navigation-related information in one centralized location. This includes all of the individual content areas within your app, called destinations, as well as the possible paths that a user can take through your app.
    NavHost: An empty container that displays destinations from your navigation graph. The Navigation component contains a default NavHost implementation, NavHostFragment, that displays fragment destinations.
    NavController: An object that manages app navigation within a NavHost. The NavController orchestrates the swapping of destination content in the NavHost as users move throughout your app.
    As you navigate through your app, you tell the NavController that you want to navigate either along a specific path in your navigation graph or directly to a specific destination. The NavController then shows the appropriate destination in the NavHost.

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

  • @dychak
    @dychak 4 года назад +11

    Man, I saw 2 official videos already and still didn't get what it is. Your video finally triggered my mind. I think the visual aid in your video helps a lot.

  • @gamessss_
    @gamessss_ 4 года назад +12

    I am doing a google course for the same topic and yours is heaps better! Thanks for this! Life saver

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

      same i was doing from udacity

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

      same here... despite being the maker of it they couldn't explain it 😢

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

      yeah, easy to understand and better than Android official team documentary video

  • @XaeroDegreaz
    @XaeroDegreaz 4 года назад +55

    At about @8:33 when he starts typing out "view.textField1" that's because he has applied the "kotlin-android-extensions" plugin in the app's build.gradle. Looks like a Kotlin plugin that creates extension functions for Views so you dont have to "findViewById()" all of the time.
    I'm not sure if that was already covered in a previous video of yours, but maybe adding that to the description, or something, could eliminate a little bit of confusion :D Thanks for the video

    • @sidecharacter9375
      @sidecharacter9375 4 года назад +2

      YOU just SAVE MY LIFEE, thanks man.

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

      thanks

    • @周叡霆
      @周叡霆 3 года назад +1

      thx. you help me a lot.

    • @ПавелПрялкин-я6х
      @ПавелПрялкин-я6х 2 года назад +6

      ​@@周叡霆 Also the java code for the:
      View view = inflater.inflate(R.layout.fragment_second, container, false);
      TextView textView = view.findViewById(R.id.textView2);
      textView.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Navigation.findNavController(view).navigate(R.id.action_secondFragment_to_firstFragment);
      }
      });
      return view;

  • @yimingchu3176
    @yimingchu3176 4 года назад +2

    Fantastic video!! This is even better than the official docs and tutorial!! Respect

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

    The clearest and best tutorials on the internet! Man

  • @kaszabi9427
    @kaszabi9427 4 года назад +4

    you just made my day! thank you so much for this

  • @telloborneo3635
    @telloborneo3635 4 года назад +2

    great videos !!,
    Please make video about handling the backstack, its so difficult for me..,
    this is my cases, here the flow of navigation graph :
    1. A-B-C
    2. D-B-F
    The question is, how the B fragment knows, which fragment that called them, from A or D, i mean how to handle onBackpress,
    im glad if u have the solution, thanks dude!

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

    I just subscribed your channel because I've been searching for difference between data binding and view binding and I found yours useful.
    So I liked this video before I start it ❤️❤️❤️❤️❤️

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

    i have read severals books, they couldnt explain simpler like you. i get so well now

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

    Would be cool to have xml and design tabs open for those of us that prefer the xml

  • @pythonsamurai
    @pythonsamurai 3 года назад +13

    Своих всегда можно узнать по акценту.

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

      жаль что не по "нашему" этот наш "свой" рассказывает

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

      он поляк

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

      @@denzmc серб

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

    Muito bom o vídeo, muito bem explicado. Sensacional.

  • @niko3359
    @niko3359 3 года назад +3

    Could you also please add the java code to your description. That really helped in your last video. Thank you for these amazing tutorials!!!

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

    add this in gradle(module) dependencies:
    apply plugin : "kotlin-android"
    apply plugin : "kotlin-android-extensions"

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

    Such a good video! You explained every important feature very well.

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

    Simple and Plain. Thank you.

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

    Terrific walkthrough, thanks!

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

    Stevdza-San saving me once again

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

      Anytime broah 🦸‍♂️🙌

  • @abhinavsingh-zc2hk
    @abhinavsingh-zc2hk 3 года назад

    Thank you so much for this amazing playlist 👌

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

    At last, I got it cleared from your video.. huge 👍 👍👍👍

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

    Thank you soo much man....please make these types of video more as it is very helpful for us.

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

    Падажжи. Зависимости нужные в градл сами цепляются, нужно только разрешить? А мы копировали из техдокументации - карго да.

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

    The best explanation I've ever seen

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

    Even though it was in Kotlin language, it has been useful to me. Thanks :).

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

    Incredible explanation, thanks for this! :)

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

    good content, easy way to make watcher understand how to do. Ty so much

  • @nagarajhegde3363
    @nagarajhegde3363 9 месяцев назад

    Good simple introduction. Thank you!

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

    Good day @
    Stevdza-San. The line " view.textView.setOnClickListener {Navigation.findNavController(view).navigate(R.id.navigate_to_secondfragment)}" is not referencing or calling the "textView" id from the first fragment.
    Instead android studio is showing Unresolved reference:textView :(
    the same error happens too in the second fragment with the second fragments id(textView2) :(

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

      Kotlinx.synthetic is now deprecated, migrate to View Binding instead. I've made a video about it: ruclips.net/video/MXZz438aCDM/видео.html

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

      @@StevdzaSan Thank you 😖 I retried and watched the video multiple times, since I thought I was doing something wrong. Thanks a bunch

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

    Great tutorial! Thank you!

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

    Sir, if you don't mind, can I ask you something? Let say an app needs 3-4 different user logins (teacher, students, etc). How would you approach this issue, sir? Thank you so much

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

    Thank you so much you made my dayyyyy

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

      Happy to hear that 😁👊

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

    Very amazing tutorial.
    Very helpful.

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

    Hello.. Great explanation..
    Please Can you make video on searchview in recycler view..
    Thankyou..
    Love from India..
    And you are great..

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

    Hi sir.. I downloaded Android Studio 3.6.1. But I found a problem, there is no support repository in SDK tools! Besides, there is no android drawable importer in the Plugins. I hope you tell me about the cause and how to overcome this problem. I googled the issues and search many videos in RUclips but that was useless. Thanks

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

    Thanks a lot man, it really helped me 🙏

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

    I love you man. Thanks for the video.

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

    Really clear tutorial, thanks

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

    Interesting topic , is it new feature in the latest upd?

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

    Thanx man this was very helpful ☺️

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

    Can we navigate through multiple activities by using bottom navigation bar?

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

    I've created a navgraph but the "directions" class from Fragment 1 to Fragment 2 doesn't generate automatically. What could be wrong?

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

    at 8:34, view.textView1.setOnClickListener is giving me an error. I cannot access the textView object from view. What should I do? Do I have to configure something in the build.gradle file?

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

      View Binding

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

      @@StevdzaSan Thank you. I have configured viewBinding to true in my build.gradle file.
      what I know is I should create a lateint val binding, and use that binding object to call all my views with IDs.
      however, you have not declared any binding object in your FirstFragment.kt file. How are you calling it from a view object? Or first do I have to change something in my MainActivity.kt file, and then does FirstFragment.kt import my binding object from MainActivity.kt?

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

      @@BehruzbekOtayev Because now kotlinx.synthetic is deprecated.

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

      @@StevdzaSan thank you. I will figure it out.

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

    when we navigate to another fragment ، the data in fragment is lost , what we can do ?

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

    cute background music

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

    should the findNavController method be better called in the onViewCreated method?

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

    arigato stevdza san!!

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

    Excelente vídeo! Ajudou muito!

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

    I can't figure out how to do this with fabs. I'm working across fragments and activities. Using the fab to navigate between activities, can't find any examples of this though

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

    Thx for the lesson. It was easy to understand

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

    thank u so much

  • @fahadhabibjanjua
    @fahadhabibjanjua 11 месяцев назад

    simple and fun

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

    You are the best❤️

  • @MoXyiD
    @MoXyiD 4 года назад +2

    Hey! Great videos! I was wondering if there will be a tutorial on how to navigate from a single fragment using numerous buttons which lead to more than one other fragment. like 1 fragment leads to 2+ others.

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

      Are you looking to inflate 2 fragments simultaneously side by side? If that is the case then try to make a fragment with 2 child fragments(which you want to inflate) and make the parent fragment in the nav graph!

  • @Jaimecoder
    @Jaimecoder 8 месяцев назад

    Machaa Allah machaa Allah machaa Allah, Allah yberek fik doctora! Et bravo Mr le journaliste pour cette belle émission et votre compétence, Merciii

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

    Amazing video !

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

    I have a doubt that if I press back button when I was in first fragment it move to second fragment instead back button has to pause the activity

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

    great Work
    🤩💙

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

    I have to put someting on my main activity?

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

    Great video, awesome thanks

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

    how can you change the fragment from the activity, I ask because I want one specific fragment to show some settings when the user select a settings menu?

  • @KL-es9bt
    @KL-es9bt 3 года назад

    How to make those fragments take up status bar as well?

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

    Hi, but How to send data from one Fragment to another Fragment in this way?

  • @harshpatel-bt5wr
    @harshpatel-bt5wr 3 года назад

    how can we handle multiple navigation graphs in app ?

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

    Thanks

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

    Thank U For this great video.....

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

    how to do the same with back button?

  • @NamNguyen-ql6ov
    @NamNguyen-ql6ov 2 года назад

    great video, tks very muchmuch

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

    how do you make this work with binding?

  • @pyaesonehan19
    @pyaesonehan19 6 месяцев назад

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

    Your Google Play Store link does not work... What happened?

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

    How to open any fragment from any other activity not the host activity

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

    Hey ,I am not getting option of textView, like view.textView1 .I am not getting it!What should I do??

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

      ruclips.net/video/MXZz438aCDM/видео.html

  • @yassinmziya2733
    @yassinmziya2733 2 месяца назад

    Make sure activity subclasses FragmentActivity 😮‍💨

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

    doesnt let me add the dependancies automatically :( just says it cant find them....

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

    I try to do this with drawer and doesn't work, somebody knows something? :C

  • @ShubhamGupta-ut4vv
    @ShubhamGupta-ut4vv 4 года назад

    onNavifationUp() is not working in Navigation Drawer Activity.

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

    How to pass data between fragments in Navigation Components

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

    best content

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

    My app display the content of activity_main.xml instead of the first fragment XML.
    How do I change it?

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

      ok I forgot the NavHostFragment in the activity_main.xml.

  • @h.r.60
    @h.r.60 4 года назад

    Keep up the great vids 👍

  • @ChinhNguyen-eg5km
    @ChinhNguyen-eg5km 4 года назад

    sr sir, can u help me with saving state fragment when navigating between fragment in Navigation component

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

      I will create a tutorial about that in the future.

    • @ChinhNguyen-eg5km
      @ChinhNguyen-eg5km 4 года назад

      @@StevdzaSan thanks sir

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

    I am actually new to Android dev, I have a question. When to use a activity and when to use a fragment??? Thanks in advance 👍👍(anyone can ans)

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

      These days you would use multiple fragments and single activity only.

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

    great

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

    why my 1 activity is not showing

  • @sumansahu1005
    @sumansahu1005 2 года назад +1

    You just speak what's going on, That is a hard to understand. it would be really great if you can add what is the intent and how in each step we can achieve it. Thank you

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

    I love you

  • @TheNitroPython
    @TheNitroPython 4 месяца назад

    This is pretty confusing, Android studio is a nightmare lol

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

    Неплохо

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

    would be nice if half this stuff actually worked lol

  • @SKYTIME-qk3yj
    @SKYTIME-qk3yj 2 месяца назад

    🇲🇾📲
    🏦📲
    🏧📲

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

    Can you please don't speed up your video.

  • @minds_clear_02.23_
    @minds_clear_02.23_ 3 года назад

    The following options can be used as viable work arounds:
    1. Retrieve the navController directly from the NavHostFragment.
    val navHostFragment = supportFragmentManager.findFragmentById(R.id.my_nav_host_fragment) as NavHostFragment
    val navController = navHostFragment.navController
    2. Post the call to the findNavController method on a handler and execute all actions that need it after that post is complete.
    3. Continue to use the fragment tag () to inflate the NavHostFragment
    issuetracker.google.com/issues/142847973

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

    I am getting error in the line : view.button1.setOnClickListener{Navigation.findNavController(view).navigate(R.id.navigateToFirstFragment)}
    Error :
    unresolved reference : Navigation