dynamic addition and deletion of items to NavigationView menu - android

My application requires NavigationDrawer to be added / deleted with entries. At present it is working without any issue.
I would like to replace NavigationDrawer with NavigationView so that I get better look minimal code.
My current nav.drawer contains default entries followed by dynamically adding /deleting entries based on user requirement.
Entries are stored in db and populated in nav drawer whenever app is opened.
I am referring
http://www.technotalkative.com/part-4-playing-with-navigationview/
I came to know with 23.0.0 and 23.1.1.. etc, there is some issue with adding items dynamically. I also want dynamic deletion of entries from NavigationView
adding, deleting items in navigation view is possible ?
any sample i can refer to learn navigationview for above operations better?

If you set your items in a menu (thing you should), you can add and remove menu items to that menu
NavigationView nav = (NavigationView)findViewById(nav_id);
Menu menu = nav.getMenu();
menu.removeItem(item_id);
menu.addItem(item_id);
In this quick introduction you can see how to set the menu items
Android Developers Blog

Related

Close collapse material drawer menu item on new fragment

Am using mike penz material drawer for my project and its working great except this issue. After visiting a previous fragment which falls under a collapse menu, say for example, Create New job as shown in the screenshot, and i go to Profile, i want the the collapsed menu for which that item falls under in this case Jobs to be closed automatically. Any help is appreciated.
The MaterialDrawer library uses the FastAdapter as adapter behind the scenes to offer expandable functionality, and additional APIs to simplify the work with the RecyclerView showing the elements.
To collapse all expanded items within the drawer, it is possible to access the expandableExtension from the MaterialDrawerSliderView, and use its API to for example collapse all items.
binding.slider.expandableExtension.collapse()
To connect this to the Drawer, call this for example when the Profile item was clicked and you were notified via the onDrawerItemClickListener
The provided sample code is based on the MaterialDrawer v8.x.y version

Bottom Menu bar with submenu

Im using the BottomNavigationViewEx library to display a Bottom Menu Bar in my android app, the library works well and fixes many of the shortcomings of the standard BottomNavigationView.
The problem comes when as per requirements I need to show 7 options in the menu, with 4 options being the direct access to their respective functionality and a "More" option, that should show a submenu with 3 more options (similar to a toolbar with items with property showAsAction="never")
Since the library does not admit more than 5 items and does not support submenus either I've been trying to implement a solution to no avail. Is there a way to implement this or any other bottom menu library that I could use that implements submenus (or lets me extend it to create a submenu)?
#Jeav148, you can take help from androidhive tab tutorial.
https://www.androidhive.info/2015/09/android-material-design-working-with-tabs/
From this tutorial you can check the scrollable tabs, so you'll be able to add tabs as much menu items you want.
Just you need to use the tablayout inside RelativeLayout with property AlignParentBottom = "true" to show the tabs at bottom.
Even though Adil's answer could have worked, I didn't go for it since it could create other problems. So I ended up making a Popup Menu anchored to the last menu item in the BottomNavigationView

navigation drawer vs navigation view which is best and what is the diffrence

i m using navigation drawer in old project but i got new project in this project they used navigation view so what is the difference beet been these two. which is the best for good for customize .
NavigationDrawer is a panel that displays the App’s Navigation option from the left edge of the screen.
and NavigationView is the builtin class/tag through which you tell the drawer what it looks like.
NavigationView consists of two main elements (these are optional):
You have to tell the NavigationView if there is any header layout:
Menu in the NavigationView
If you don't want to use both then you don't need to use it. You can simply put your custom code (XML) inside DrawerLayout.
An easy example will help you to understand all the game.
Navigation View is a widget provided by the android which you can use inside a Drawer. Navigation View makes it very easy to create a navigation menu inside your app.
Refer this for more:
https://developer.android.com/reference/android/support/design/widget/NavigationView.html
Navigation Drawer is nothing but a container where your navigation menu resides. Either you can use NavigationView for creating a highly customizable menu or you can simply use a listview to provide the menu items.

Custom Overflow Menu Outside of ActionBar

I need to implement a custom overflow menu with menu items and the overflow icon if the screen size cannot show all the icons. I cannot use a side scroll since I am already inside an expanded list view. I cannot use the Top or bottom action bar menu because the action will change based on what list item has been expanded.
So I would like to create my own overflow menu - similar to the gmail screenshots attached
Any ideas? Apparently ABS can be used for this but I can't figure it out, please help :)
ListPopupWindow is what you're looking for. It's an API 11+ class, however. ABS includes a backported version which is basically just a ListView inside a PopupWindow (both API 1 classes).

Android action bar list navigation stops working

I am using ActionBarSherlock and ViewPagerIndicator to create an activity that has both tabs and list navigation.
The tabs are backed by a FragmentStatePagerAdapter and allow the user to navigate between the different sections of the app. The list navigation allows the user to toggle the view mode of the tab they are currently on e.g. if they are viewing search results they are able to toggle between list and grid mode.
The problem that I am having is that when i scroll between the tabs the list navigation intermittently stops working. I can click on the spinner and it displays the list of options but when i select one of them the text in the spinner:
Doesn't get updated,
onNavigationItemSelected() doesn't get called.
(For some reason using a FragmentPagerAdapter rather than a FragmentStatePagerAdapter seems to stop the issue occurring as frequently but it still happens occasionally.)
Any ideas?
Thanks
I think should not use the tab navigation built in the ActionBar.
You can use the PagerTitle interface that is available in ViewPager. http://developer.android.com/reference/android/support/v4/view/PagerTitleStrip.html
Or you can use the below great libraries
http://viewpagerindicator.com
https://github.com/astuetz/PagerSlidingTabStrip

Categories

Resources