I've only been learning android for a few days now (beginner) and I'm quite not able to create a ViewPager as fine as these:
Is it possible to create a ViewPager inside a Fragment. If so any clue on how to proceed with creating such?
As a side note can some also please answer this question: I read somewhere that nested Fragments are possible, is that how these apps are created?
could you put a ViewPager in a fragmnet? Yes, Is this what they are doing? I dont know.
Quick example of setting up nested fragments is here
It could be an activity with a viewpager at the top in a scrollview too
You can do this. You have to use ViewFlipper and have multiple layouts within that PageViewer, each will be a "page." Here is a good tutorial on how to use this.
http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/
Related
In Xamarin, I currently have two different activities and I would like to combine these together and use a ViewPager.
One activity uses the following content view: SetContentView(Resource.Layout.MapWithOverlayLayout);
The second activity uses the following content view: SetContentView(Resource.Layout.HomeScreen);
Can I please have some help to code a simple ViewPager that can add the two above content views into a ViewPager and then show each of these content views via code?
Thanks in advance
For a ViewPager, you will need Fragments instead of Activities.
Here is how to implement a ViewPager with Fragments and different layouts: How to implement a ViewPager with different Fragments / Layouts
The basic idea is that you create a Fragment for every layout you have, and then inside your FragmentPagerAdapter, load the correct Fragment depending on which page you are currently on.
This is how I am doing it in my other post and sorry about not posting the same code here.
Take a look at those links. It will help for sure.
Android:How to create different view in ViewPager?
Its a pretty simple implementation. You can define your own layouts and then use it in the view pager.
Here's my other post where you can get what you want to achieve:
How to use swipe gesture in a view pager's page with android?
Hope this helps..:)
I am concern about the ViewPager or ViewFlipper. I don't want to use ViewPage. So I want to know how to swipe between Layout or activity. Can anyone suggest me with source code. Thanks in advance.
I cannot understand why you don't want to use ViewPager. You'll be able to swipe between everything you want(activity, layout). It's not difficult to use it and to customize it. There is a plenty of examples:
Fragments
General
you can easily surf through the i-net to look for more examples
I am getting stuck in one stage. I have a total of 20 to 25 images that should get animated like ViewPager does. Now on all the images I have onClick() events and I don't know if I should work with ViewPager or ViewFlipper. I can implement both things, no issues here.
What I Want : I just want a suggestion that according to my problem which will be the best option, ViewFlipper or ViewPager?
What I Have Searched : I have gone through different links on StackOverflow, namely How to improve the performance of ViewFlipper/ViewAnimator and ViewFlipper vs Fragments, but I could not find the thing I want.
I have worked with ViewPager somewhat, but at that time there were just 3 or 4 Fragments I had to manage. If I were to use it to solve this problem I have to manage 25 Fragments this time. So I am wondering if there is a better solution available.
I have also done a little R & D on ViewFliper and know that it has only one Activity I have to manage but it does not have the animation accuracy that ViewPager has.
Please suggest me whether I should go for ViewPager or ViewFlipper?
Thanks in Advance.
Update (from 5+ years old original post):
Use ViewPager2 from JetPack. That's it.
I left original answer below but just for reference. Please do not use very old and not maintained widgets (like Gallery and ViewFlipper any more):
Intro: On first thought, I would recommend Gallery widget instead of ViewFlipper but it is depreciated since JellyBean (API 16), probably because of bad recycling of non-visible elements implementation.
Answer: What u really should use now is ViewPager or HorizontalScrollView. In your case (despite not too much given details) I think is better ViewPager because according to documentation:
.. HorizontalScrollView is a FrameLayout, meaning you should place one
child in it, containing the entire contents to scroll ..
On the other side for ViewPager you should implement PagerAdapter to generate pages which will be shown in this view.
My final answer is A, ViewPager ;)
Hope u will find this helpful ;) Cheers
Think I have an activity with some layouts, I want to know is it possible to use layouts in activity for thats activity ViewPager items ?
is it possible ? if so , how ?
thanks
You should use a ViewPager, where each page holds a Fragment. This sample code explains how it can be done.
If you want your application to support pre-Honeycomb devices, you'll want to use the ViewPager and Fragments from the Android Support Package.
You can use viewpager with fragment. See the sample code below. I think this will be helpful for you.
http://developer.android.com/resources/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.html
Actually I want to create three listviews with the help of fragments. Is it possible? if possible then please give some reference.
Try this one.
https://github.com/JakeWharton/Android-ViewPagerIndicator/