I am currently building an app with admin and user. I've used the template bottom navigation menu method. I've created two versions of the menu for admin and user. How will I be able to switch these two out at any point?
to switch between the two versions the bottom navigation menu, you can use the setOnNavigationItemSelectedListener method in the navigation view. This method allows you to set a listener that will be triggered when the user selects an item from the bottom navigation menu.
You can then use an if-else statement to determine if the user is an admin or a user and switch out the menus accordingly. You can also use the getMenu method to get the menu items and then use the setVisible method to hide or show certain menu items.
Related
I try to put the bottom navigation bar under Google Map and I can't. When I tap the second button of navigation bar I want to open google map fragment but the bar stays at the bottom. Does anyone know how it can be done?
Here is an example of exactly what I want:
My app uses a bottom navigation layout and loads up three fragments (on one of them is a google map fragment), hence the bottom navigation menu stays there for all the three fragment of the app!
If you want to have a screen where the bottom navigation isn't present, why not use an activity with a layout without a bottom navigation view for that screen ? The user will just navigate back to the previous activity when the job is done.
I'm making a simple android app, and I'm trying to work out the best way to make the main menu. The users of this app are not likely to be that sophisticated, so I want to make it as simple as possible.
So I want the first screen they see when the app opens to be this menu - they click on what they want, and it takes them to that part of the app (Not pressing a "Menu" button to bring it across from the left, which is common nowdays).
So, I want the menu to look a bit like this: http://cloud.addictivetips.com/wp-content/uploads/2012/10/AppZapp-Android-Menu.jpg , minus the search box, and the strip down the right hand side. (also this looks like it is one of those menus that slide out from the left, which I dont want)
I have had a look into menus (https://developer.android.com/guide/topics/ui/menus.html#options-menu), but it seems it is more used for contextual stuff, or letting the user select an option), then a navigation menu.
So - what is the best way to do this? Do I just create a list and put a button in each item?
Based on the your requirement , Use Navigation drawer see the below link.
Navigation drawer tutorial
NavigationDrawerSample
After used navigation drawer, you need to add search view on navigation header.For more info see the link
SearchView tutorial
I have a Option Menu that opens when I'm clicking the menu button on a android smartphone. And I wonder if there is some way to call the onCreateOptionsMenu and onOptionsItemSelected method from a onClick method for a button. So when I click on a button in my app instead of clicking the menu button on the smartphone.
You can invoke Activity.openOptionsMenu to show the options menu.
You should not invoke onCreateOptionsMenu(…) directly; this method is for the Android UI framework, not for you. If you need this method to be called again, for example, to refresh the menu items, you can call invalidateOptionsMenu() and Android will re-initialize the menu.
The same goes for onOptionsItemSelected(MenuItem). If you need to make the app do something that normally happens when a particular menu item is selected, simply put that something in a separate method that you invoke from onOptionsItemSelected as well as from anywhere else you need it.
normally when the menu button is pressed , the menu appears from the center bottom of the screen. Is there a way to make it appear from sides.
On Android 3.0 and higher, items from the options menu are presented by the action bar which is standard way to provide access to menus and normally menus appears from top right corner. You should go through this once:
Menus Action Bar
as the title suggests I'm trying to add code to my app which allows the user to click on an item in the action bar menu which then unfolds a drop down menu (spinner class?) containing a few options such as lamp, tv etc. - each with an icon. The user will then be able to select one of these and drag and drop the icon (or an image representing the icon) to the canvas where it is then drawn. What is the best way to go about this?
If you're referring to the ActionBar overflow menu items, then you would have to take a look at the code for the ActionBar in the framework and extend it in your application, but that would firstly require quite a hassle and secondly would break compatibility when changes are made to the ActionBar in new versions of Android.
Also, this goes completely away from what the ActionBar is intended to be. You should only have actions in the overflow menu, not contain elements that directly interact with the Activity content. It's just wrong. Consider redesigning your UI so that you implement the requested featured inside the content view, not on the ActionBar.