I am using a Navigation Drawer currently with the Android Example. I plan to change this to using SlidingMenu Library as it's easier and provides easy customisation methods. I will also use the SherlockActionBar. I will have about 4-5 different Activities and each will have different ActionBar actions depending certain states. For all the Activities, I want to display the same Navigation Drawer/Sliding menu. Currently, I am using Fragments as per the Android Example to switch and inflate new Layouts each time a new item is selected from the drawer. As this is done inside the MainActivity, all four xml layout's share the same .java Activity file which makes it long and messy.
Using the SlidingMenu Library and SherlockActionBar, can I avoid Fragments and singular Activity and link the same Navigation Drawer/Sliding menu to all the Activites?
Yes, you can use one SlidingMenu for all the activities. Make a separate base activity and implement slidingmenu in that Activity and extend all the activities in your project with that activity.
Related
I'm a beginner in Android. I have a project with multiple activities and I need to add a navigation drawer to this project instead of a normal menu. I added a new navigation drawer activity, but it doesn't show in my previous activities.
Should I add something to my existing activities?
All the tutorials I have watch use fragment while I use AppCompatActivity.
So I don't know how can I add it to my project.
Can you help me, please?
to do that, you have to use fragments instead of activities. fragments are easier to work with navigation drawers than activities. 1st you have to create a main activity for navigation drawer. Change your other activities to fragments. Then you can have navigation drawer in all the fragments. Refer below video it has everything you want. if there is any problem ask. https://www.youtube.com/watch?v=-SUvA1fXaKw
I had an app which was developed 2 years back, now I want to add navigation drawer to that app, but the problem is in that app there are 15 Activities, so do I need to apply the Navigation drawer for all 15 Activities? or is there best way to implement this.?
The navigation drawer items are common for whole app.
Can anyone suggest me the best way to implement this.
A way you can do it, since Navigation Drawers are just list fragments, is create a list fragment and recall that same fragment in all the activities that you want it in. You can do this using the XML Layout Editor to place the fragment in the layout.
Having so many activities, however, makes it a lot of work (especially if your app is designed for multiple sizes and each activity has a layout).
I am developing an Android project with Android Studio.
I would like to have the menu is always accessible in every view like Google Play Store (the Sidebar) and App Store (the Bottom selection bar).
I am thinking to do it in two ways:
Make my app have only one activity with Navigation Drawer, all the other views are above this activity using fragments.
Recreate the sidebar or bottom selection bar every time I switch to another activity.
Both of these two ways are very complex and cost a lot. Do you have some better ways?
PS: If not, could you suggest me some links about how to implement these two methods?
Thanks a lot.
you can create a MasterActivity that extend Activity and contain your sidebar. other Activity can extend from your MasterActivity by this way you can access your sidebar on each activity.
I think you should use the default navigation drawer and default action bar.
If you are using the Android Studio then
right click on your package and go to New/Activity/Navigation Drawer Activity.
That will create navigation drawer fragment and activity automatically.
But If you are using Eclipse then these links will be useful for you.Navigation Drawer
Action Bar
you can use include tag in other layout activity and call Navigation Drawer:
<include
android:id="#+id/nDrawer"
layout="#layout/your_NavigationDrawerLayoutName"/>
So I have an app where in one of the screens there is a sliding menu (jfeinstein's) and I also want to implement a tab view using fragments. For this I need to extend the FragmentActivity but I have already extended SlidingActivity and I can't extend more than one class. Is there a way to work around this so that I have both a sliding menu and a tab menu in the same class?
Instead of extending the Activity you can integrate it, as listed in point 1 of the usage guidelines.
"You can wrap your Activities in a SlidingMenu by constructing it programmatically (new SlidingMenu(Context context)) and then calling SlidingMenu.attachToActivity(Activity activity, SlidingMenu.SLIDING_WINDOW | SlidingMenu.SLIDING_CONTENT). SLIDING_WINDOW will include the Title/ActionBar in the content section of the SlidingMenu, while SLIDING_CONTENT does not. You can check it out in the example app AttachExample Activity."
- GitHub page, usage section
The SlidingMenu was written for a time when the navigation drawer pattern didn't have a native implementation in the SDK. There is one now: you can use the NavigationDrawer which is included in the v4 Support Library. There is a guide for that here on the developer pages.
I'm looking through the ActionBarSherlock samples demo, and I see that the List Navigation and the Tab Navigation both make use of the ActionBar's setNavigationMode method. This tells me that you can only have one or the other. If I want the user to have list navigation to move around between activities but I want some activities to have tabs, is there a different way to add tabs than via navigation mode? Is it against ActionBar design guidelines to use both? I don't look at tabs and consider this to be a navigation feature, so I find it odd that you get one or the other.
This tells me that you can only have one or the other
Correct. Bear in mind that with action bar tabs, Android will convert you to list navigation, on its own, in certain configurations, whether you like it or not.
If I want the user to have list navigation to move around between activities but I want some activities to have tabs, is there a different way to add tabs than via navigation mode?
You can use a ViewPager with PagerTabStrip or the tab flavor of ViewPagerIndicator.
Or, you can go retro and use TabHost and TabWidget.
Is it against ActionBar design guidelines to use both?
The design guidelines refer to them as separate options for "View Controls". More importantly, given the automatic conversion of tab navigation to list navigation, it would be seriously confusing for the action bar to have two Spinners' worth of navigation choices.