Navigation drawer use at another activity only, not in main activity - java

I have a project containing different activities like: main activity, signup activity, login activity and track activity. Now I want to create another activity which will contain navigation drawer. And the point is "I don't want to use navigation drawer at any other activity".
All the example so far I found at searching # net provide example using main activity. But I don't want to use navigation bar at main activity.

If you are using Android Studio, follow these steps,
1. Right click on app.
2. new -> activity -> navigationDrawerActivity
this way only your new activity will have navigation drawer.

Related

Go back to specific Fragment in Navigation Drawer from Activity

I would like to know how do I go back to a specific Navigation Drawer Fragment from a activity.
For example:
Navigation Drawer Menu Options:
Home Fragment
Products Fragment (Lists products, the user can click product to edit product activity)
Other Fragment
Now when I go back (Toolbar back button & android back button) from the Edit Product Activity it goes back to the MainActivity which has the Navigation Drawer, but it goes to the Home Fragment. I would like when the user goes back on the Edit Product activity to go to the Products Fragment.
How do I achieve this?
Thanks in advance.
Have you tried navigation component? https://developer.android.com/guide/navigation/navigation-getting-started
I fixed my issue by adding android:launchMode="singleTop" to my MainActivity class in the AndroidManifest.xml file.

Batch edit activities in Android Studio

I have recently decided to add a Navigation Drawer to every screen in my app. I already have the working code. Is there a faster way to add the same layout to every screen or must I do this manually?
One way you could do it is to create an Activity or Fragment class say BaseActivity that all your Activity or Fragment will inherit, and put your Navigation Drawer logic there.

Side bar in android

Does anyone know what this UI element is called in Android, and where to look for the documentation to implement such a layout.
Yup its called a navigation drawer, here is a link to some documentation https://developer.android.com/training/implementing-navigation/nav-drawer.html. Also I believe its one of the standard options when creating an initial project
Navigation Drawer Android Example as follow:
http://javatechig.com/android/navigation-drawer-android-example
its called navigation drawer in android.
to add navigation drawer simply follow these steps-
in android studio go to file - new project - your application name click on next - next - to add an activity scroll down in pop up window - and select navigation drawer activity click to next - type activity name as required - finish.
it will add navigation drawer in your project.
This type of user interface is the most common User Interface used in modern android apps. It is called a Navigation Drawer. The drawer stays outside the screen on the left/right side(where you choose it to be) and comes to action when you click the open drawer button.
For development reference, you can head over to the documentation page.
If you want to add a new such activity to your app, you can click New>activity>Navigation Drawer Activity.
Or when starting a new project, on the Add an Activity to Mobile Screen Page, you can select a Navigation Drawer Activity.

Why use fragments in navigation drawer?

I followed this tutorial about navigation drawer androidhive-navigation drawer and it has used fragments for the list items.
Similarly all sources I found use fragment views for individual list items. I have these issues.
Why use fragments, when we can use an ordinary Activity class?
Going with the link example, if I have Home Activity class implemented before, what should I do to convert it to a fragment?
If Home is the main activity, what happens then?

Navigation Drawer app behaivour when open fragments

Im working with a Android app that uses Navigation Drawer. This app use the template provided with Eclipse ADT (when you select the navigation drawer template).
I dont understand the behaivour of the navigation drawer very well.
My main requeriment is make a "search" option, I have on the Navigation Drawer a EditText to get the query string from the user. I want that I press search button and open my SearchFragment getting the search query.
I know that I can make this:
Bundle args = new Bundle();
args.putString("searchQuery",searchQuery);
fragment.setArguments(args);
And this for getting:
getArguments().getString("searchQuery");
But I have the next:
MainActivity
NavigationDrawerFragment
SearchFragment
OtherFragments.. (I think this arent relevant in the question)
I dont understand where I can make this steps.
More data:
I have in the navigation drawer class the EditText with the setOnEditorActionListener for the search press.
Any info that I can add I will be add. Sorry my english
Thanks for the help
Navigation drawer is basically a component that show 2 pane in the way that one is the main pane (usually fragment) that is used to show content and the other one is usually a listview that is just used to choose which fragment to show in main pane
so if you want to switch between 2 different layouts you have to create 2 different fragments and then you can add or replace these fragments based on listview's selected item.
You may refer to below link for complete code
http://developer.android.com/training/implementing-navigation/nav-drawer.html
Hope it helps!

Categories

Resources