I just want to create a navigation drawer activity. When I Right click on app > new > activity > navigation drawer activity, nothing happens! it just creates a xml file in menu directory. i tried deleting android studio and user preferences files and reinstalling it, but still having the same problem. any suggestions?
First of all , you should create a new activity called navigation drawer activity , you just need to follow these steps : file > new > activity > navigation drawer activity . Then you can modify the xml content and create a navigation drawer like you want .
first create a new project with navigation drawer.
file > new project>navigation drawer activity. and then add content to the template
Make sure all navigation drawer activity files are safely deleted. This means all resource xml files. Also check whether the activity is created in AndroidManifest.xml, if it is remove the said activity.
After deleting all the xml and java files related to navigation drawer you even need to Delete these lines:
"implementation 'androidx.navigation:navigation-fragment:2.3.2'
implementation 'androidx.navigation:navigation-ui:2.3.2'"
in you app.gradle module,then try creating a navigation drawer activity named MainActivity2.
May be the android studio version you are using has problems. I think you are using android studio canary version. Try using stable version. If you are already using stable version then clear data and all the details and start project again.
Make sure that you have deleted all the files related to your previous navigation drawer activity. !!
And also remove the dependencies that were added during your first import.
Related
How an I make my own template activity like those prebuid in Android studio…and add my own on that Android activity creation page?
I have choosen navigation drawer activity..
For my project I have edited the fab button etc...
But the problem is that I want 200 same layout activities with my options
Is there anyway I can load my own in the add activity option
Or
I have to edit the same for 200 times. ?
Thanks in advance....
An Android Library will do what you want.
Inside Android Studio go to File > New > New Module > Android Library and follow the prompts in the Wizard.
If you need to do more than the basics with it, I suggest this tutorial which goes more in depth.
I am new to Android Studio. Following the tutorial given by developer.android I have created a new project. They asked to create a blank activity and as there is no one such, I have used Empty Activity as the template. Then the tutorial said that there will be a content_main.xml inside res/layout folder, but I didn't find one. Did I build the correct Application? What probably may be the wrong? Thanks in advance.
content_main.xml file will be generated when you choose "blank activity" . This activity will be having floating button by default at the bottom of the screen.
But when you choose "empty activty" then content_main.xml won't be generated and it won't be having floating button , but just simple activity.
So for your tutorial choose "blank activity" and then your tutorial will run fine
You need to select basic activity when creating a project. that will give you the 2 files content_main.xml and activity_main.xml
content_main.xml is used to handle the contents of the activity(like buttons, textView etc). So when we choose an empty activity, there are no components and hence the layout content file i.e. content_main.xml is not created. If you choose a blank activity there will be a floatingactionbutton component and hence there will be a content_main.xml created. So hopefully this will solve your problem. You can delete the floatingactionbutton later if you want your activity to be blank.
Try to close and reopen the Android Studio. I hope this works!
On the top right corner of the android studio code there is a search icon.
Click that and type: content_main.xml
You'll get the file over there open it.
I am working on navigation drawer and have Android studio 1.4. I have read that in 1.4 we don't require fragment java files and can use " onNavigationItemSelected" in MainActivity file itself and trigger action on the basis of menu selected. Now my doubt is do i require the corresponding layout files for these menus and same task can be done in the header content xml file created by android studio itself??
Regards,
Navin
I have started Android project.Now(in middle of the project) i got new requirement to add Navigation drawer.is it possible to add now?. I tried to change the main_activity.xml . it's not working.....
Android Studio automatically creates a NavigationDrawer Activity for you. Right-click and highlight the option to create a new activity. This will display the various types of activities you can use. Select NavigationDrawer Activity and the mainActivity, navDrawerFragment, activity_main.xml, and navdrawer.xml files will be created for you.
I am trying to create a search interface. I have searched a lot and created xml folder in my res folder manually and placed searchable.xml file inside res/xml.
Now when i am trying to add this file in AndroidManifest.xml with code
It is showing me error with red-line under "#xml/searchable" and saying "Top level Element is not completed". How to fix it?
That is part of a Navigation Drawer flow, (it isn't a menu and doesn't drop down).
As terrible as link only answers are, it's the only option here as I can't possibly cover it with the depth the developer docs do: https://developer.android.com/training/implementing-navigation/nav-drawer.html
Gmail use material navigation drawer and this three bar is button to open navigation list......
Tutorial on material navigation this
Github project : this