How to creat a Navigation drawer in android studio kotlin

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

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

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

    I love how your codes are clean and straight to the point!👏

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

      Glad to hear that😀

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

      Please would the nav drawer work if if I don't want the toolbar to be visible?

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

      @@justeben you can use the Activity theme: Theme.NoTitleBar (with this code your action bar disapear) and your navigation drawer open with swipes a finger from the left edge of the activity.if you mean not this , pls let me know :)

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

      It works but how to make the hamburger sign show is a challenge.

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

      you can create custom action bar , and inside your custom action bar , you can put hamburger sign to control your drawer :)

  • @pagal_scientist
    @pagal_scientist Год назад +3

    I was learning from old outdated videos and facing problems of depcrecation and errors. Found your channel and I am blessed

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

    Your explanations are very clean and easy to understand. Thank you so much for the content.

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

      You're very welcome! glad you like them 😊✨

  • @dr.michaelscoutelis368
    @dr.michaelscoutelis368 Год назад +1

    A highly educational video and one of the most understandable and clear codes. ❤❤❤

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

      Really glad to hear that you like the video 😊🙏

  • @bodormarcel4373
    @bodormarcel4373 Год назад +1

    Same for me... and at least it works 😀 - Congratulations !

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

    your tutorial was amazing thank you very much it was a life saver😇

  • @divyayash5858
    @divyayash5858 Год назад +1

    Well explained and to the point.

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

    Like always great reyhaneh😍✨

  • @igormorozov6311
    @igormorozov6311 Год назад +1

    thank u very much, very helpful🌼

  • @arturoiniguezmejia1740
    @arturoiniguezmejia1740 Год назад +2

    excellent video, it helped me a lot 😃, could you help me with how to pass data to change the textView inside the nav_header, please 😓For example data I get from a login :(

  • @mahshad.a
    @mahshad.a Год назад +1

    hey, i love your video. however i have some problem on binding. the binding.apply didn't work on my laptop. what should i do?

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

      Thanks for your feedback 😊glad you liked the video 😊 please check this video :
      ruclips.net/video/JxsJxuNIcMk/видео.html

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

    Thank you in advance

  • @EsrefCimcim
    @EsrefCimcim Год назад +1

    thanks

  • @luisdanielfigueroagarcia317
    @luisdanielfigueroagarcia317 Год назад +1

    hi, thank fot you video, i have a questin, How i can close the menu when i tap del option?

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

      you're welcome , in our example , you can use : drawerLayout.closeDrawers() for closing navigation drawer after clicking on each item 😊

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

    if someone can't see the ActivityMainBinding, just add (dataBinding true) in (buildFeatures{})

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

      you can add viewbinding= true inside your buildFeatures body 👍

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

      @@AndroidGeekCo well, i use both, one to create the navigator bar and de second to made the activity code

  • @alemibughunter
    @alemibughunter Год назад +1

    i loved

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

      glad to hear that 🤩✨ thanks for your feedback 🙏🏻

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

    Menu does not open when click hamburger menu. What's problem? That say deprected for onOptionsItemSelected. That can be reason? How can I solve it?

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

      do you use the codes that I show in this video? or use another code? because the code that I used is not deprecated. Now, I checked again, and it works as I expected. would you please tell me exactly which code cause to error? and also please check your dependencies version , I used the last version for all my dependencies

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

      @@AndroidGeekCo I use it for fragment. So I can't click it from fragment? It works when I swipe screen from left to right. But dont work when click hamburger. Also it can be deprected for fragment.

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

      I got , let me check it for fragment , just as suggestion , you can use single activity , and then in your activity , yoy can use drawer with out any problem , and this way is mush more modern instead of using just fragment

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

      @@AndroidGeekCo I do navigation compoenent. I did it for MainActivity that works. It's all about fragment. Thanks for your helping.:)

  • @VinothS-i8x
    @VinothS-i8x Год назад

    i have followed your code but navigation drawer button not showing me ... if i swipe on the screen from left side drawer menu it will come.. how can i fix this ?? pls help

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

      same for me the hamburger menu is visible, but if I touch it the window hide , did you found a fix ?

    • @supermurloc5371
      @supermurloc5371 8 месяцев назад +1

      Hi. I don't know if the problem is relevant at the moment, but still. I also followed the code from the video, just like you. The same problem has arisen. The solution is that you need to initialize the Toolbar in the Activity.xml and Activity.kt
      for Activity.xml
      --- in ConstraintLayout ---
      // initialize the Toolbar with the code

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

      @@supermurloc5371 thank u very much 🙏🙏🙏

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

    how do we redirect to another activity from navigation drawer in kotlin

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

      in this video, we use => [ when (it.itemId) ] for accessing each item of our navigation drawer instead of show toast that we have done in this video, you can use intent for going to another activity like this -> startActivity(Intent(this,SecondActivity::class.java))

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

      @@AndroidGeekCo thanks

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

      @@AndroidGeekCo Can you tell me what is wrong in my code
      lateinit var binding: ActivityMainBinding
      lateinit var toggle: ActionBarDrawerToggle
      override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      binding = ActivityMainBinding.inflate(layoutInflater)
      setContentView(binding.root)

      binding.apply {
      toggle = ActionBarDrawerToggle(this@MainActivity, homeMain, R.string.open, R.string.close)
      homeMain.addDrawerListener(toggle)
      toggle.syncState()
      supportActionBar?.setDisplayHomeAsUpEnabled(true)
      navView.setNavigationItemSelectedListener {
      when (it.itemId) {
      R.id.loginBtn -> startActivity(Intent(this@MainActivity, LoginActivity::class.java))
      }
      true
      }
      }
      }
      override fun onOptionsItemSelected(item: MenuItem): Boolean {
      if(toggle.onOptionsItemSelected(item)){
      true
      }
      return super.onOptionsItemSelected(item)
      }
      }

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

      menu item is not clickable why it is

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

      Please check your code again with the video and GitHub source : github.com/ezatpanah/Navigation-drawer-RUclips , as you can see in the video when I click on each item of menu, the toast has appeared and it's works

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

    Hi i have a problem, the DrawerToggle doesnt show up, what should i do?

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

      would you please write your code about toggle here

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

      @@AndroidGeekCo
      private lateinit var toggle: ActionBarDrawerToggle
      override fun onCreate(savedInstanceState: Bundle?) {
      toggle = ActionBarDrawerToggle(this, binding.notebook, R.string.open_drawer, R.string.close_drawer)
      binding.notebook.addDrawerListener(toggle)
      toggle.syncState()
      supportActionBar?.setDisplayHomeAsUpEnabled(true);
      }
      override fun onOptionsItemSelected(item: MenuItem): Boolean {
      if (toggle.onOptionsItemSelected(item)){
      return true
      }
      return super.onOptionsItemSelected(item)
      }
      notebook is my drawerLayout

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

      your code seems right... 🤔 is there your code on github? maybe I can take look into whole your code...

    • @ErickRodriguez-vf9qt
      @ErickRodriguez-vf9qt Год назад

      I have the same problem and i don´t know how to solved it

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

    How this drawer work on other Activities??