It is possible to have a Navigation Drawer and a FragmentActivity which has also swiping tabs?
E.g. When I select an item in the menu, a swiping tab view should appear.
To answer your question - yes, it is absolutely possible. Navigation Drawer Swipe Views
Just follow above tutorials and combine them.
Related
I have a bottom navigation view in Activity with 4 menu items (4 different fragments) that switches between them. The question is: how can I go from that menu fragment to another fragment that is not included in bottomnavigationview (deeper fragment hierarchy). I am using Android Navigation Framework to switch between fragments.
You could use a navigation drawer or tabs as well.
You can find more info here
I am using the new Navigation Components library. I have a Navigation Drawer in place that works perfectly fine.
If my user logs in I want to change the menu of the Navigation Drawer. Specifically, I want to change the "Login" item to "Logout" from within a fragment.
All the solutions I found online didn't use Navigation Components. So therefore, they recommended something like this:
// Get the navigationView and swap the menu
NavigationView navigationView = view.findViewById(R.id.nav_view);
navigationView.getMenu().clear();
navigationView.inflateMenu(R.menu.activity_main_drawer_logged_in);
However, this doesn't seem to work in my case (I cannot get the navigationView from within a fragment). How does one achieve this with Navigation Components?
You can access Activity from Fragment through interface:
Create and interface say LoginSuccessListener
Implements this in your Activity
Inside fragment receive this listener inside onAttach
Use it as you needed to update Navigation Menu
I'm new to Android development. I get that a NavigationView is an AppBar (i think). What makes these two different? I want to create a custom "appbar/toolbar" with a centered logo and menu/settings button in the top right corner (instead of the standard left) which reveals a drawer.
I was going to ditch the built in appbar/toolbar all together and just create my own somehow and include button overlay which displays a drawer.
What would you do? Navigation view, app bar, or custom toolbar from scratch? I don't know what the standard is or what is acceptable. What is the difference between a navigationview and appbar. Thank you.
edit: I'm slowing realizing that an appbar is one feature within a navigation view, among others like a drawer layout, menu items etc... i think.
1. NavigationView
By using NavigationView, we can bind the menu directly with NavigationView. This is the benefit of the NavigationView. No need to create ListView and adapter with navigation drawer. By default we can get selector of item click. With menu we can change the color of icon of selected menu.
For more details :
1.https://developer.android.com/reference/android/support/design/widget/NavigationView.html
http://www.technotalkative.com/part-4-playing-with-navigationview/
2. AppBar
Appbar is for toolbar with scrolling effect. We can easily give the material design effect.
For more details :
1.https://developer.android.com/reference/android/support/design/widget/AppBarLayout.html
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.
I've been looking for an answer to this for a while but I haven't found any answers on the subject.
So I have my Main Activity which containers a toolbar, a nav drawer, and a frame layout (the container for my fragments). So on the start of the activity it starts a fragment to display and I can switch between different fragments and they all have the toolbar and nav drawer because their container is still main activity.
Except there is one problem. I want to make a new fragment and I don't want it to use a nav drawer or a toolbar. I figured out how to disable and hide the toolbar from within that specific fragment but I haven't been able to find out how to disable the nav drawer. The user can still swipe from left to right to open the nav drawer. I don't want them to be able to do that.
Also if I was going to disable it, I need to disable it from the fragment not the main activity because the navigation to this fragment is from a button that's inside another fragment
You can use :
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
This will lock drawer opening on swipe
Source : How to Disable drawer in fragment and back back to correct fragment