Viewpager inside a fragment is it possible - android

I want to know whether its possible to create a following UI in android.
I am having a navigation drawer. It calls fragment A as the main UI. In fragment A i want to use viewpager to display different tabs.

Yes, it is possible. Just implement the Sliding Menu Library, and when you click a Menu Item from the Sliding Menu, start an FragmentSlidingActivity(Fragment Activity extends SlidingMenu's FragmentActivity to be able to slide) which has Tabs with Fragments inside.
And if you are looking for different back stack for each tab under Tab Host (like it is used to be with TabActivity which is deprecated ), you can take a look on my example project on GitHub.
Here is the link to the Sliding Menu Library.
See as suggested: https://github.com/JakeWharton/Android-ViewPagerIndicator
or this for a quick tutorial: http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html

Related

Adding a navigation drawer to an existing project

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

Navigation Drawer and sliding Tabs

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.

SlidingMenu Library - can I use same Sliding menu for various activities?

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.

How to use Sliding Activity and Fragment Activity in a single class?

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.

Fragments Within Fragment Tabs

I'm building an application that requires Tabs, which are now deprecated. The dev guide says to use Fragments to replace the tabs instead. However, my application needs to have fragments within each tab, which means fragments inside fragments, which isn't allowed. Does anyone know of a possible work around for this?
While the action bar support for tabs is designed to make it easy for the contents of a tab to be a fragment, that is not strictly required. You could use ViewFlipper, repeated calls to setContentView(), or something to arrange to change other stuff when the action bar tab is selected.
Prior to the native action bar (Android 1.x/2.x), either stick with classic tabs, or use something like Action Bar Sherlock to get an action bar and tabs.
I fake tabs by having a "tabs" fragment across the top that contains multiple toggle buttons. Below that I have a merge view containing a separate fragment for each tab.
I respond to taps on a toggle button by toggling the other buttons "off", showing the fragment for that "tab", and hiding the others.
its little late , but yes you can :) here's an example
but for fragment inside fragment inside tab isn't an android native way, you have to start a new fragmentActivity if you want to show detail of fragment. you can but is not an android way !

Categories

Resources