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
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
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
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.
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?
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 :-)
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
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
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 :)
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
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
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?
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 "
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.
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
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
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 :-)
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.
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
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.
@@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;
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?
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.
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?
Watch Kotlin Version of Navigation Drawer Menu in Android Studio:
th-cam.com/video/sSL6a_ivRVk/w-d-xo.html
The best tutorial and the least seen, thank you sincerely!
Glad, your welcome 😊
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
Thnk you very much for this tutorial
17:44 brother in my case it is not taking id instead showing error "constant expression required"
Try using if else.
@@android_knowledge terimakasih banyak
@@android_knowledge thx bruh
Nice tutorial, helps me a lot!!! thanks!
what alternative did you use for onBackPressed? it is depreceted in SDK 34
very useful, thank you so much..
que buen tutorial, tuve varios problemas pero al final agarro y mi wbd de app se ve bonita xdxdd
Ready, suscribed!
Very best and easy understanding thank you👍
😊👍🏻
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.
same here sir
Very good information you help me, thanks.
your are the best man!!!!!!!
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
Maybe because ypur action bar is in the same color as the background try pressing in random places where he should be.
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
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.
Nice onee💯
Thanks 🔥
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?
Use if else instead of switch case.
@@android_knowledge THANK YOU SO MUCH, YOU SAVED ME
Plz give me code if you solved it.....
@@narancia7577???
@@Whoizme-w8d
Put this line
android.nonFinalResIds=false
In this file and sync
gradle.properties
How to user profile show on navigation header bar??
can i still use this way on activity? bcs i have one activity page?
nice 🤩🤩😍
Thanks :-)
Excellent tutorial, one question, how do I change the color of the status bar? now it's gray
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 :-)
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
nice video
i hope you would explain the codes just like the other videos where they explain what these codes do..
I will do, soon :-)
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
Are you available for a custom job?
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
Both of them are in strings xml.
thanks for the tutorial. how to change the background color of that menu?
If you want to change the color of menu, then go to activity_main and in navigation view change the background color.
@@android_knowledge thanks for the reply, i will try
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 :)
nav_view is present in activity_main at 11:06 timestamp :-)
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
Hi! Best tutorial ever
You can refer the below video:
th-cam.com/video/xqtem37z4Tk/w-d-xo.html
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
Replace switch case with if else.
For more detail, watch the below video:
th-cam.com/video/HIBO5lgsKU8/w-d-xo.html
onBackPressed not working I tried with adding toat message in onBackPressed function it also don't see that toast message
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?
Check the below link, you might found your solution in it :-)
stackoverflow.com/questions/41320456/android-app-always-show-app-name-in-toolbar
bro please help me bro switch case error bro
Use if else instead of switch case.
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
Use Intent for switching from activity to activity in switch case :-)
onBackPressed is depreceted in sdk 34, any alternatives?
Check the below link:
stackoverflow.com/questions/72634225/onbackpressed-is-deprecated-what-is-the-alternative
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 "
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.
Make sure you are using if else instead of switch case :-)
I use if else instead of Switch Case, the program does not give an error message.@@android_knowledge
@@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
?
The nav_header page is not merging with activity_main.xml file. Whyy?
same problem
Can the drawer stay open even if I click on it?
how to set color menu icon
Could you show the imports, I get errors not detected by R.id.nav_home and those that follow :(
same to my last project i try, still giving me errors
@@jonarcvasquez8989 si lo solucione, cambie el switch por condicionales if
Moisés, podrías pasar ese código?
Is there any way that it is not by the fragment, I mean that it is by the activity
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
in case i need to use activity means how?
You can check the below video:
th-cam.com/video/JR-OylAhK_s/w-d-xo.html
Can this be done in cotlin?
Yes, I'll upload soon :-)
@@android_knowledge How to Login connect with Navigation Drawer Menu?
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
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 :-)
Same error sir how to solve this🥺😔
i think you missed adding a line in AndroidManifest.xml
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.
Same error I'm getting bro
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
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.
@@android_knowledge Okay thank you
Can i add this project into sign up project ?
I have problems with the fragment_container :c It shows an error and I dont know what to do ;-;
What is the error?
Hover on fragment container, it will show the error.
My app is not even running. It is getting closed. Any suggestions? and i have no errors
Check logcat.
The fragments dont switch when clicked for me, any idea what might be causing this?
There might be some issue with the switch case code.
@@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;
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?
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.
Hey, where's the Source code?
Please find link in the description box :-)
errrorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr toggle style humbuerger menu ? ? ? ? / ? ?
Make sure to set parent theme as no action bar instead set custom toolbar with ActionBarDrawerToggle.
these errors do not allow me to launch the application😪
May I know the errors captured in logcat?
Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements
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;
}
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?
Instead of using switch case, use if statement.