Navigation Component Crash Course - Android Kotlin Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ก.ย. 2024
  • 📗 Get the code from this tutorial 👇👇
    resocoder.com/...
    Start saving time now by planning weekly with Week Sweep: bit.ly/2Jf3QA0
    Navigating between fragments and activities in Android can sometimes be confusing. Not to mention the amount of error-prone boilerplate code you have to write. While Kotlin simplifies a lot of things when it comes to fragment transactions and starting activities, there's still a lot of room for improvement.
    Navigation Architecture Component libraries will help you solve your complex navigation demands. They let you skip fragment transactions by abstracting it in the form of simple to use navigation destinations. You can set up these destinations in a friendly-looking drag and drop editor.
    Navigation Architecture Components support easy way of deep-linking into a specific place in your app and they manage the back-stack for you. With these libraries you can even pass arguments between activities or fragments in a type-safe way.
    Go to my website for more information, code examples and articles:
    ● resocoder.com
    Follow me on social media:
    ● / resocoder
    ● / resocoder

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

  • @brainfunmax2845
    @brainfunmax2845 5 ปีที่แล้ว +4

    24:55 navigateUp error
    To fix it replace the code
    return NavigationUI.navigateUp(drawer_layout, Navigation.findNavController(this, R.id.nav_host_fragment))
    with this code
    return NavigationUI.navigateUp(Navigation.findNavController(this,R.id.nav_host_fragment), drawer_layout)
    28:00 Unresolved reference: setNumOfPhotos
    comment the code like this //nextAction.setNumOfPhotos(random.nextInt(100)) so you can run it.

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

    Great Explanation, Awesome Tutorial. Thanks !

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

    at 28:00
    There is a kotlin plugin for safe args which is available apply plugin: "androidx.navigation.safeargs.kotlin"

  • @ArturoMartinez-uz5sw
    @ArturoMartinez-uz5sw 5 ปีที่แล้ว +7

    Can you please make one tutorial, mixing MVVM with the Navigation Component ??

  • @abhithakral3989
    @abhithakral3989 5 ปีที่แล้ว +6

    I am unable to get create navigation controller checkbox while creating a project. I am using Android Studio 3.4 Canary build and i have tried it on android studio 3.2 stable build also. Can you help me out what can be the problem.

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

      having the same problem did you get any solution

    • @extremovimiento8909
      @extremovimiento8909 5 ปีที่แล้ว

      developer.android.com/guide/navigation/navigation-getting-started#Set-up - developer.android.com/jetpack/androidx/releases/navigation#declaring_dependencies

    • @extremovimiento8909
      @extremovimiento8909 5 ปีที่แล้ว

      luego creas el directorio "navigation" con el archivo " mobile_navigation.xml " y sigues el tutorial

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

    great tuto as usual!...just for curiosity, what font are you using in your android studio? it looks nice! :)

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

    Hey there! Are you planning to make a Kotlin tutorial series just like your C# tutorials? 😊😊 It's really entertaining to watch you doing stuff in android studio but i don't even know kotlin enough yet and it would be so good to learn from you. 😶😶😶

    • @ResoCoder
      @ResoCoder  6 ปีที่แล้ว

      Hello! I'm really happy that you'd like to see a Kotlin series from me. I'm currently not planning to do it. I feel that Kotlin is simple to grasp once you know C# or Java. Kotlin also has one of the best official docs I've ever seen.

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

    None of the following functions can be called with the arguments supplied:
    public open fun navigateUp(@NonNull p0: NavController, @Nullable p1: DrawerLayout?): Boolean defined in androidx.navigation.ui.NavigationUI error that i get when i download the git project and run it in my AS

    • @DenMaxProd
      @DenMaxProd 5 ปีที่แล้ว

      Having the same issue

  • @OlegGolubev_yolo
    @OlegGolubev_yolo 5 ปีที่แล้ว

    wow, that "let" function is pretty good, hungry for kotlin documentation now >.

  • @tricksilver04
    @tricksilver04 5 ปีที่แล้ว

    Hi @Reso Coder with androidx, the view ids on xml becomes actual views, but ids follow a non-uppercase convention which also is a problem when the view is used as java/kotlin objects which is using a camelCase convention. Which do you think should we follow in naming these views?

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

    whats the approach of navigation component using bottomappbar instead of bottomnavigationview ???

  • @RobertPetras
    @RobertPetras 5 ปีที่แล้ว

    Great tutorial Reso Code, Thanks!

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

    What if I wanted the settings icon to be visible on the homescreen only? Can somebody please help me with this?

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

      You can use a navigationchange listener in the navcontroller class, but, you must knos what are u doin for that

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

    Can you explain how to restrict fragment recreation when bottom menu click again

    • @marspumpkin
      @marspumpkin 5 ปีที่แล้ว

      I have been struggling with the same problem

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

    Really awesome

  • @kehinsoftcompanyltd8397
    @kehinsoftcompanyltd8397 5 ปีที่แล้ว

    Please how to change bottom Nav Menu icon when it's Active from Inactive state? For example, if I want my menu icon to be an outline icon and when user click on it, it changes to a filled icon with the color changed or another icon? so, the user would know the present tab they're on?

  • @michalrv3066
    @michalrv3066 5 ปีที่แล้ว

    Any chance you have in plans making a tutorial about animating toolbar changes when using navigation components? I have been trying to set animateLayoutChanges property to the toolbar but for some weird reason it was positioning title in the wrong place when navigating back and was quite laggy for some reason.

  • @x-techoholic3818
    @x-techoholic3818 5 ปีที่แล้ว

    how can we use the custom back button on a custom toolbar for going to previous fragment using android navigation component ?

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

    thanks, great explanation

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

    Working fine, however there is need to manage back stack, All fragment stay in stack and when I press default back button all my journey of visited fragment repeat. How can handle back stack using navigation architecture ?

    • @Umutto3211
      @Umutto3211 5 ปีที่แล้ว

      in the navigation page click to action settings and you can create a pop action

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

    Thank you so much !

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

    Awesome!!!!!!

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

    Hello,
    i would like you to explain more about safe args in kotlin and provide me some resources to learn more about this

  • @nanderson815
    @nanderson815 5 ปีที่แล้ว

    Good stuff, thank you!

  • @Mehul.K
    @Mehul.K 5 ปีที่แล้ว

    Keep it up !!!

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

    great job you helped me )

  • @robgas45
    @robgas45 5 ปีที่แล้ว

    Cool bro. Thank you...!!!

  • @pravindharam3514
    @pravindharam3514 5 ปีที่แล้ว

    Hi buddy, can you please explain how to remove a fragment from stack manually and clear all fragment stack. Like previously we use popbackstack function

  • @michalsvec8703
    @michalsvec8703 5 ปีที่แล้ว

    Hi, how to save state of fragements when using this jetpack navigation ? OnSaveInstance doesn't work

  • @mbarkimohamed9275
    @mbarkimohamed9275 5 ปีที่แล้ว

    i think that this make the navigation more complex

    • @SociedadAndroide
      @SociedadAndroide 5 ปีที่แล้ว

      its easier, since you dont need to handle FragmentTransactions manually

  • @sathishgadde1924
    @sathishgadde1924 5 ปีที่แล้ว

    How to manage fragment state duting backstack. Like first contains recyclerview and user scroll to end then onitemclick navigate to second screen. now if user back to previous fragment there is not state managed. it is possible or not.if possible how to manage ?

    • @saurabhkhare2749
      @saurabhkhare2749 5 ปีที่แล้ว

      You can use app:popUpTo="@+id/fragment_home" on action

    • @sathishgadde1924
      @sathishgadde1924 5 ปีที่แล้ว

      @@saurabhkhare2749 State not retained in this case. Have you checked this condition.

    • @AndrewZayts14
      @AndrewZayts14 5 ปีที่แล้ว

      @Sathish gadde, hello, did you found a solution?

  • @bazoka113
    @bazoka113 5 ปีที่แล้ว

    Hi, i wonder if we can change the navigation icon and the back icon on toolbar ? i try research but no result :(

  • @h3w45
    @h3w45 5 ปีที่แล้ว

    Thank you.

  • @uiltonKeyboard
    @uiltonKeyboard 5 ปีที่แล้ว

    Hey buddy, great tutorial! Congratulations!
    By the way, is there any way to add swipe pages? In the past, we used to implement the ViewPager, and nowadays how this will work?
    Thanks in advance.

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

      i know Im randomly asking but does anybody know of a trick to log back into an instagram account??
      I was dumb forgot the account password. I would love any help you can give me!

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

      @Levi Kendrick instablaster :)

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

      @Lucca Mathias thanks so much for your reply. I found the site through google and im waiting for the hacking stuff now.
      Seems to take a while so I will get back to you later with my results.

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

      @Lucca Mathias It did the trick and I finally got access to my account again. Im so happy!
      Thank you so much you really help me out :D

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

      @Levi Kendrick Glad I could help :)

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

    Can you pls share your theme and color schema

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

      If you're still interested in it it's an android studio plugin called Material Theme UI, using the Darker theme.

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

    what font are you using?

  • @youdube1203
    @youdube1203 5 ปีที่แล้ว

    what is the theme that you are using?:) plz

  • @sathishgadde1924
    @sathishgadde1924 5 ปีที่แล้ว

    How to prevent fragment recreate during pop behavior ? Like Second fragment to first fragment .

  • @akashjyani2646
    @akashjyani2646 5 ปีที่แล้ว

    Hi which theme u use in android studio

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

    crash cource without nested graph? same examples everywhere :/

  • @MichaelMooring
    @MichaelMooring 6 ปีที่แล้ว

    Be sure to turn on the experimental Navigation editor here: developer.android.com/topic/libraries/architecture/navigation/navigation-implementing
    To be able to view the nav graph editor at 16m8s

  • @johnneijzen
    @johnneijzen 5 ปีที่แล้ว

    Is there way to make this work with Navigation drawer instead of bottom Navigation

  • @baranidharanmurali469
    @baranidharanmurali469 5 ปีที่แล้ว

    No coding related question alert!
    Which screen recorder do you use?

  • @yogeshkurane123
    @yogeshkurane123 6 ปีที่แล้ว

    Any idea when will A.S 3.2 be released on stable channel?
    Because the latest goes 3.1.4 August & its full of design preview bugs (coordinator layout & BottomAppBar) it has made the dev. life cycle harder than better

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

      I'd like to know that too! I'm using 3.3 canary and I didn't have any problems though. Maybe I'm just lucky.

  • @abdallahhussein5997
    @abdallahhussein5997 6 ปีที่แล้ว

    hi thank you a lot. you helped me to be comfortable in kotlin but i have one problem. android studio is too slow to the extent that i can't do my project at all is there any alternative for android studio or can I use intellj ide and emulator to create android apps please may you help me please coz i have stop everything about android app and if it's possible can you make a tutorials to do that?. or i have forgotten to mention my Computer features i5 8 ram 500gb hard disk. i can't wait to see your reply

  • @imAbhishekTomar
    @imAbhishekTomar 5 ปีที่แล้ว

    @ResoCode - How can I use FAB with bottom navigation? Any one please help.

  • @darkhan-yt
    @darkhan-yt 6 ปีที่แล้ว

    I think each tab should contain it's own backstack. By pressing camera tab, application shouldn't have back (arrow) button in toolbar. How we can achieve it?

    • @ResoCoder
      @ResoCoder  6 ปีที่แล้ว

      I thought the same but then I read a comment on an issue on GitHub. It turns out that Google changed their material design guidelines.
      Now it's actually correct to have a back button after switching tabs with BottomNavBar.

    • @evgeniivorobei69
      @evgeniivorobei69 5 ปีที่แล้ว

      @@ResoCoder , so, can we have separate backstack for each tab? In your video: go to camera->photos, switch to home tab, switch to camera again. I expect to see photos (each tab has it's own history), but you'll see there just first fragment ("CAMERA"), not "PHOTOS"

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

    Hello guy , I want to know your android studio version and their theme

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

    Interesting addition of line 50 in MainActivity.kt. But I thought that if onOptionsItemSelected() returned false it called the super() anyway. Doesn't your code cause the super() to potentially be called twice (if the super returns false the first time)?

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

    too much intro and too much side talks about other projects..only searched for navigation component

  • @askskater
    @askskater 5 ปีที่แล้ว

    33:48 and in drupal 8 ... lol