Does anyone successfully implemented Navigation Drawer with Fragments, Up Navigation and ActionBar?
As stated in documentation Up Navigation works automatically with Activities. But If I want to implement Navigation Drawer, then I have to use fragments.
I have set:
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
I also put all fragments to BackStack. When checking listener OnBackStackChangeListener, I see that BackStack is being checked, but the Up navigation arrow doesn't show up.
Navigation Drawer with Fragments
take a look at this question and this may also help you. As stated in the second link, you don't "have to use Fragments to use the NavigationDrawer"
Although many navigation drawer examples show how fragments can be
used with the navigation drawer, you can also use a
RelativeLayout/LinearLayout if you wish to use the drawer as an
overlay to your currently displayed Activity.
This is actually the approach I've used in one of my recent projects and it works fine.
Related
I have an android app that uses legacy TabHost, its deprecated but still works fine.
Requirement is to add a sliding Navigation Drawer to the TabHost. Menu in the Nav drawer will be a combination of tabs in the tabhost plus additional items.
Can anyone provide examples of how to integrate Navigation Drawer with TabHost?
thanks!
Section 3.2 in this article explains quite well how to implement the navigation drawer. In this example they set it up with a header and a RecyclerView, but you can really build it however you like.
I hope this helps
I want to use navigation drawer and tabs together.I have googled it but i didn't get correct answer,even I am confused whether to use or not when i use navigation drawer I use the FrameLayout and for tab also I use FrameLayout how do i differentiate them how can I use.Can anyone explain me.Previously action bar were there but, now they are deprecated. I am using toolbar.
Thanks in advance.
I want to use navigation drawer and tabs together.
Why? Navigation Drawer gives user clickable options and when an item is selected, developer has to change the fragment in the Activity's FrameLayout.
Tab view is also an alternative, i.e. you can have all drawer options in form of 'swipe-able' tabbed fragments, using viewPager.
Now you should decide, to go with drawer or viewPager
Alternatively, if you do want to use both in your app you can go for a viewpager inside slidingDrawer. Now ViewPager will have tabbed swipe view and slidingDrawer options can open new Activities.
Let me know of your decision and then I can update here with appropriate code snippet/links.
I want to use Navigation drawer in Action Bar and below that I want to use Swipe Tabs in single sherlock fragment. I want to open above sherlock fragment on the Item click of ListView.And Most Important think is that I want to open different swipe tab on the click of different Item in ListView.
thank in advance.
Use this library. Because Navigation Drawer with swipe tabs is really difficult and as far as I know many developers are struggling with it. For reference you can refer my Application.
Create the Navigation Drawer with the standard procedure and just integrate the above library.
Hope it helps
I am using action bar with help of android-support-v7-appcompat and also using Navigation drawer over it.
In one of my fragment if I use ActionBar.Tabs then the tabs overlaps the navigation drawer and the drawer gets below the ActionBar tabs.
How can I make the action bar like in google play application or Google movie application.
The tabs should also go behind like the fragment. How can I do the same with android-support-v7-appcompat Libs
For Tab bar try ViewPagerIndicator http://viewpagerindicator.com/
This has a very good implementation for tab bar.
When we use default tab bar with actionbar, in landscape mode it will be merged into single row. So its better to use the above library.
I think you would be better off using a library like ViewPagerIndicator. The ActionBar is recognized as decor and is shown over top of the window, and the DrawerLayout is drawn as an object in the window.
Not sure if they're going to fix it in a future revision, but ViewPagerIndicator is pretty easy to set up and customize anyway.
Also, go to this question for better achievement getting-drawerlayout-to-slide-over-the-actionbar
Roman Nurik says that the Navigation Drawer should not be used with the Action Bar tabs.
The discussion is here https://plus.google.com/u/1/116515063230772720916/posts/8dWEkFcbTFX
So I'm working on adding ActionBarSherlock and the Navigation Drawer to a project that previously implemented a custom (very poorly written) "action bar". Instead of using fragments and a backstack of activities for navigation, some activities show and hide different layouts. (That is, suppose I am in a list mode and then select a button to go into an edit screen. The app currently hides the list layout and shows another layout.).
So I've added actionbar sherlock and a navigation drawer to all the activities. I want to be able to programmatically switch the navigation icon from the 3 lines to the arrow when certain buttons are pressed.
I can't figure out how to do this though. Any ideas?
Thanks!
The solution to this problem is to use the method:
setDrawerIndicatorEnabled(boolean enable)
inside the ActionBarDrawerToggle class.
After:
drawer.setDrawerListener(toggle);
Use this code:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.select);
It depends how wedded you are to built-in actionbar artifacts. You can always redraw the current actionbar by inflating a layout of your choosing, then calling
getSherlockActivity().getSupportActionBar().setDisplayShowTitleEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowHomeEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowCustomEnabled(true);
// Inflate and do whatever you need to your view...
getSherlockActivity().getSupportActionBar().setCustomView(abView);
getSherlockActivity().getSupportActionBar().show();
When you want to go back to your standard (assuming you're using a DrawerLayout to do your navigation drawer), you can just set make a call to setDisplayShowCustomEnabled(false) (re-enable showHome and showTitle as you please).
As far as I know, customization of the back button can only be done via themes. Besides, swapping the drawer icon for the back icon (within the same Activity) doesn't make sense, since users would still be able to access the navigation drawer by sliding the left most edge to the right. It just wouldn't make sense.
If you absolutely need the back icon, then it would make the most sense to make that screen a new Activity since you would indeed be adding another "level" to the stack, which is what the back icon represents.