Navigation Drawer Menu in Android Studio using Java | 2024

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ธ.ค. 2024

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

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

    Watch Kotlin Version of Navigation Drawer Menu in Android Studio:
    th-cam.com/video/sSL6a_ivRVk/w-d-xo.html

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

    The best tutorial and the least seen, thank you sincerely!

  • @michaelrivas8600
    @michaelrivas8600 5 หลายเดือนก่อน +2

    Hola, me da gusto ver este video y poder hacer que me funcionara el codigo tuve problemas igualmente el la linea de codigo R.id.nav_home y los demas pero lo que hice fue que en ves de usar swich utilice el if y el else si alguno tiene duda pidanle al chatgpt que los ayude a cambiar el swich por el if y el else y listo copien y pegan jajjaja

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

    Thnk you very much for this tutorial

  • @heptanegaming5191
    @heptanegaming5191 4 หลายเดือนก่อน +4

    17:44 brother in my case it is not taking id instead showing error "constant expression required"

    • @android_knowledge
      @android_knowledge  4 หลายเดือนก่อน +1

      Try using if else.

    • @TaufikWandani-e2r
      @TaufikWandani-e2r 3 หลายเดือนก่อน

      @@android_knowledge terimakasih banyak

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

      @@android_knowledge thx bruh

  • @kimsan8997
    @kimsan8997 10 หลายเดือนก่อน

    Nice tutorial, helps me a lot!!! thanks!

    • @ChrisPugsworth
      @ChrisPugsworth 9 หลายเดือนก่อน

      what alternative did you use for onBackPressed? it is depreceted in SDK 34

  • @hkthktm
    @hkthktm 10 หลายเดือนก่อน

    very useful, thank you so much..

  • @gametony2169
    @gametony2169 6 หลายเดือนก่อน

    que buen tutorial, tuve varios problemas pero al final agarro y mi wbd de app se ve bonita xdxdd

  • @kimsan8997
    @kimsan8997 10 หลายเดือนก่อน

    Ready, suscribed!

  • @sathishKumar-hm1ij
    @sathishKumar-hm1ij ปีที่แล้ว

    Very best and easy understanding thank you👍

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

    Hello, i tried your tuto but in the activity_main it doesnt acknowledge toolbar it's in red and i cannot use it. Could u help me please.

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

    Very good information you help me, thanks.

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

    your are the best man!!!!!!!

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

    Hi may I know why my action bar not appear on MainActivity but my app's name still appear at the center of the screen. My text on fragment_home got dragged to the bottom because of that app's name

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

      Maybe because ypur action bar is in the same color as the background try pressing in random places where he should be.

  • @taufikhidayah8791
    @taufikhidayah8791 9 หลายเดือนก่อน +3

    Sir why my navigation drawer isn't working when I clicked any of the menu? It doesn't navigate to the fragment. Instead, the drawer just close without doing anything

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

      Did you follow his tutorial or did you start with the Navigation Drawer Views Activity template? Because I'm using the template and I can't click the buttons either. I can open and close the menu, but I can't click on the items in the menu. He starts from an empty views template here, so I was hoping that it would have a different result. I haven't been able to find any useful information on this yet.

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

    Nice onee💯

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

    Hello, in the part of MainActivity.java, the code gives me this error error: constant expression required
    case R.id.nav_home:
    And I didn´t find a wat to fix it, please, could someone help me?

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

      Use if else instead of switch case.

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

      @@android_knowledge THANK YOU SO MUCH, YOU SAVED ME

    • @Whoizme-w8d
      @Whoizme-w8d ปีที่แล้ว

      Plz give me code if you solved it.....

    • @Whoizme-w8d
      @Whoizme-w8d ปีที่แล้ว

      ​@@narancia7577???

    • @ranggaaiman1272
      @ranggaaiman1272 10 หลายเดือนก่อน +3

      @@Whoizme-w8d
      Put this line
      android.nonFinalResIds=false
      In this file and sync
      gradle.properties

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

    How to user profile show on navigation header bar??

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

    can i still use this way on activity? bcs i have one activity page?

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

    nice 🤩🤩😍

  • @KaizenRank-SSS
    @KaizenRank-SSS ปีที่แล้ว

    Excellent tutorial, one question, how do I change the color of the status bar? now it's gray

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

      Add new style in themes.xml where parent will be NoActionBar and colorPrimaryVariant will be your desired status bar color.
      Watch my upcoming video on Navigation Drawer in Kotlin, it will be more clear to you :-)

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

    Es muy importante la funcion "onBackPressed",porque a mi no me manda a los demas fragments, y no se si sea por la version pero a mi la funcion me la tacha

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

    nice video

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

    i hope you would explain the codes just like the other videos where they explain what these codes do..

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

    How to remove the button from the nav bar and put it outside the nav bar, because I want to hide this nav bar and have the menu button in my xml page

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

    Are you available for a custom job?

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

    Hey Sir,where are open_nav,close_nav locate in line ActionBarDrawerToggle toggle=new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.open_nav,R.string.close_nav);.I don't see in this video.Please helps me

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

      Both of them are in strings xml.

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

    thanks for the tutorial. how to change the background color of that menu?

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

      If you want to change the color of menu, then go to activity_main and in navigation view change the background color.

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

      @@android_knowledge thanks for the reply, i will try

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

    Nice Tutorial, it's a bit hard to read because of auto-completion but with some Pause it's (almost) working fine! One Question: You call nav_view later (navigationView = findViewById(R.id.nav_view) -> where did you get that from? I can't find any nav_view, maybe I overlooked it :)

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

      nav_view is present in activity_main at 11:06 timestamp :-)

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

    Your channel all the videos are outstanding and easy to understand thanks for it and sir i need one help(about the app development) can i get your contact

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

    Hi! Best tutorial ever

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

      You can refer the below video:
      th-cam.com/video/xqtem37z4Tk/w-d-xo.html

  • @AmparoRodríguez-s1v
    @AmparoRodríguez-s1v ปีที่แล้ว

    hello, in the java of MainActivity it gives me 5 errors
    which are in nav_share, nav_home, nav_settings, nav_about and in nav_logout. I've been trying to figure it out for hours, but I just can't. says: constant expression required.
    could you help me? Plz

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

      Replace switch case with if else.
      For more detail, watch the below video:
      th-cam.com/video/HIBO5lgsKU8/w-d-xo.html

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

    onBackPressed not working I tried with adding toat message in onBackPressed function it also don't see that toast message

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

    Hey, thank you for the nice tutorial. In the top bar of my app next to the menu icon, it says "com.example.myapp.android...". Can you tell me where i can change that?

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

      Check the below link, you might found your solution in it :-)
      stackoverflow.com/questions/41320456/android-app-always-show-app-name-in-toolbar

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

    bro please help me bro switch case error bro

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

    if i want to change from the fragment (from the switch case ) to new activity how do i do that? also thx for the vid

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

      Use Intent for switching from activity to activity in switch case :-)

  • @ChrisPugsworth
    @ChrisPugsworth 9 หลายเดือนก่อน

    onBackPressed is depreceted in sdk 34, any alternatives?

    • @android_knowledge
      @android_knowledge  9 หลายเดือนก่อน +1

      Check the below link:
      stackoverflow.com/questions/72634225/onbackpressed-is-deprecated-what-is-the-alternative

    • @eren352
      @eren352 9 หลายเดือนก่อน

      getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
      @Override
      public void handleOnBackPressed() {
      // Menutup aktivitas ketika tombol kembali ditekan
      finish();
      }
      });
      "I don't know if this is true or not, I use chat gpt "

  • @SüleymanArslan-p5z
    @SüleymanArslan-p5z ปีที่แล้ว

    Although it does not show any errors, I cannot click on the Home settings share areas. When I click it, it does not give any errors and it does not switch between fragments.

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

      Make sure you are using if else instead of switch case :-)

    • @SüleymanArslan-p5z
      @SüleymanArslan-p5z ปีที่แล้ว

      I use if else instead of Switch Case, the program does not give an error message.@@android_knowledge

    • @eren352
      @eren352 9 หลายเดือนก่อน

      @@android_knowledge
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {
      int itemId = item.getItemId();
      if (itemId == R.id.nav_home) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new HomeFragment()).commit();
      } else if (itemId == R.id.nav_settings) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
      } else if (itemId == R.id.nav_share) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ShareFragment()).commit();
      } else if (itemId == R.id.nav_about) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit();
      } else if (itemId == R.id.nav_logout) {
      Toast.makeText(this, "Logout!", Toast.LENGTH_SHORT).show();
      }
      drawerLayout.closeDrawer(GravityCompat.START);
      return true;
      }
      //Is that true

    • @eren352
      @eren352 9 หลายเดือนก่อน

      ?

  • @pavithiras.1464
    @pavithiras.1464 ปีที่แล้ว

    The nav_header page is not merging with activity_main.xml file. Whyy?

  • @hendrixp.1199
    @hendrixp.1199 ปีที่แล้ว

    Can the drawer stay open even if I click on it?

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

    how to set color menu icon

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

    Could you show the imports, I get errors not detected by R.id.nav_home and those that follow :(

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

    Is there any way that it is not by the fragment, I mean that it is by the activity

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

      There is a way but I will recommend to use fragment instead of activity :-)
      1. Fragments over Activities:
      stackoverflow.com/questions/10478233/why-fragments-and-when-to-use-fragments-instead-of-activities
      2. Navigation Drawer with Activity:
      th-cam.com/video/JR-OylAhK_s/w-d-xo.html

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

    in case i need to use activity means how?

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

      You can check the below video:
      th-cam.com/video/JR-OylAhK_s/w-d-xo.html

  • @tioe-e7m
    @tioe-e7m ปีที่แล้ว

    Can this be done in cotlin?

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

      Yes, I'll upload soon :-)

    • @tioe-e7m
      @tioe-e7m ปีที่แล้ว

      @@android_knowledge How to Login connect with Navigation Drawer Menu?

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

    Thank you very much for this video , but actually I am getting two errors which are,
    1. error: incompatible types: android.widget.Toolbar cannot be converted to androidx.appcompat.widget.Toolbar
    setSupportActionBar(toolbar);
    2. error: incompatible types: android.widget.Toolbar cannot be converted to androidx.appcompat.widget.Toolbar
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
    Please help me solve them

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

      Both errors are similar, checkpoints:
      1. At 14:45, initialise androidx Toolbar not android in MainActivity.
      2. At 15:00, I have corrected my mistake and used androidx Toolbar in activity_main xml.
      Hope, that works for you :-)

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

      Same error sir how to solve this🥺😔

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

      i think you missed adding a line in AndroidManifest.xml

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

      15:05 , line 20, replace Toolbar with androidx.appcompat.widget.Toolbar toolbar = ... That worked for me. I don't know why it's not marked as error in the video though.

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

      Same error I'm getting bro

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

    How to solve if the problem is
    `@layout/activity_main` does not contain a declaration with id `drawer_layout`
    Cannot resolve symbol 'drawer_layout'
    Cannot resolve symbol 'nav_logout'
    Anyone please help meeee

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

      1. Make sure in activity_main, the parent layout is drawer layout with id as "drawer_layout".
      2. Also, make sure in nav menu there is an id present as nav_logout.
      3. If none of this works, try clean project or invalidate caches.

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

      @@android_knowledge Okay thank you

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

      Can i add this project into sign up project ?

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

    I have problems with the fragment_container :c It shows an error and I dont know what to do ;-;

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

      What is the error?
      Hover on fragment container, it will show the error.

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

    My app is not even running. It is getting closed. Any suggestions? and i have no errors

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

    The fragments dont switch when clicked for me, any idea what might be causing this?

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

      There might be some issue with the switch case code.

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

      @@android_knowledge i have triple checked to make sure it looks exactly like the one you provided
      case R.id.nav_settings:
      getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout, new SettingsFragment()).commit();
      Break;

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

      Same with me... I tried writing a Toast to check if the items are being clicked but looks like the items aren't being clicked... Did you find any solution?

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

      Checkpoints:
      1. If fragments are not switching then check if frame layout is properly associated or not.
      2. If toast is not working when clicked on item then there might be some issue with item id or onNavigationItemSelected.
      3. Check if any error is captured in logcat.

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

    Hey, where's the Source code?

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

    errrorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr toggle style humbuerger menu ? ? ? ? / ? ?

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

      Make sure to set parent theme as no action bar instead set custom toolbar with ActionBarDrawerToggle.

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

    these errors do not allow me to launch the application😪

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

      May I know the errors captured in logcat?

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

      Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements

    • @masterwesley-ok7le
      @masterwesley-ok7le ปีที่แล้ว +1

      instead of switchcase: if else
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {
      int itemId = item.getItemId();
      if (itemId == R.id.nav_home) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new HomeFragment()).commit();
      } else if (itemId == R.id.nav_settings) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
      } else if (itemId == R.id.nav_share) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ShareFragment()).commit();
      } else if (itemId == R.id.nav_about) {
      getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit();
      } else if (itemId == R.id.nav_logout) {
      Toast.makeText(this, "Logout!", Toast.LENGTH_SHORT).show();
      }
      drawerLayout.closeDrawer(GravityCompat.START);
      return true;
      }

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

    Hello i am having an error at the last step of the video:
    case R.id.nav_home:
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new HomeFragment()).commit();
    break;
    case R.id.nav_settings:
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingFragment()).commit();
    break;
    case R.id.nav_logout:
    Toast.makeText(this, "Logout", Toast.LENGTH_SHORT).show();
    break;
    i am getting errors in
    case R.id.nav_home:
    case R.id.nav_settings:
    case R.id.nav_logout:
    can you help or can you message me directly?

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

      Instead of using switch case, use if statement.