3

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

Philipp Jahoda
  • 47,594
  • 21
  • 164
  • 175
Garry
  • 1,181
  • 8
  • 24
  • 44
  • Refer this one http://developer.android.com/training/animation/screen-slide.html. Also you can extends your adapter to PagerAdapter in which you can call your views. – Piyush Mar 14 '14 at 07:47

2 Answers2

1

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.

Community
  • 1
  • 1
Philipp Jahoda
  • 47,594
  • 21
  • 164
  • 175
0

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..:)

Community
  • 1
  • 1
mike20132013
  • 5,257
  • 3
  • 28
  • 41