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
Related
In my android app, i am having NavigationDrawer. Now, i want that when i click on any navigation-item, then
1) left drawer should remain open
2) previous listitem should be replaced by item-click content
3) item click content should be loaded within navigation view.
I searched but found few links suggesting to use ExpandableListview. Is there any facility to expand or collapse content of navigation item?
Is it according to android design patterns? if its possible then please suggest that how can i achieve it.
Thank you.
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
I use this library:
https://github.com/mikepenz/MaterialDrawer
I would like to have a right NavigationDrawer with a ListView (or a lot of items) inside and I get items from DB inside the Fragment and when user click on items on the NavigationDrawer I get data from another DB and show it on Fragment.
and I have a questions:
is possible to create a right Drawer inside a Fragment? or is better to create a new right Drawer in MainActivity and change the navigation item inside the Fragment?
Just use brand new Navigation View from recenlty released Android Design Support Library by Google.
Here are links for you:
official documentation, always a good read: https://developer.android.com/reference/android/support/design/widget/NavigationView.html
nicely written blog post about Navigation View: http://antonioleiva.com/navigation-view/
and last but not least, sample app using new Android Design Library: https://github.com/antoniolg/MaterializeYourApp
To have Navigation View on the right, just set android:layout_gravity to end.
As from design point of view, you should always use left sided Navigation Drawer, it is possible to make it right sided, but its recommended to leave it at the left side.
Another thing is that you do not need to use 3rd party navigation drawer libraries.Since there is a Design library by google, which supports the material design navigation view.
Here is a link for the library:
https://developer.android.com/tools/support-library/features.html
And here is another useful link:
https://guides.codepath.com/android/Design-Support-Library
Here is the link for the Navigation Drawer: https://guides.codepath.com/android/Fragment-Navigation-Drawer
As for your question the appropriate way is to create the drawer always in the main activity onCreate() method.
I am working on an application, in which I need to implement navigation drawer. We have two different ways of implement navigation drawer in android as shown in attached screen shots :
In first way the sliding list is over main content. In second type, sliding list becomes visible and make main content to slide left to right with Navigation Drawer list.
I goggled a lot about this and only got solution of first type. I want to implement Navigation drawer like second type in attached screenshot. So please tell me what changes I need to make.
Thanks.
For the first case google's official Navigation Drawer is there.
And for the second case there's a third party library on github.
here's the link: https://github.com/jfeinstein10/SlidingMenu
Also I feel you've to use ActionBarSherlock (again a third party library) in order to implement the second case.
Moreover the google's drawer method is the recommended one as it supports a stable action bar, from where you can choose items even when the drawer is open. Also the design + app flow is slick and faster in this case as compared to the third party lib.
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