Hi,
I am trying to implement the ViewPager specifically swiping with tabs in 4.0 and the actionbar.
I have not been able to find any Xamarin documentation and am hopeful the community can assist me with an example.
Issues faced, I have located ViewPager in Android.Support.V4.View but it can not be added into your layout with the designer, I have not been successful adding it programaticaly either
Any help appreciated
Thanks
Here was a failed attempt
public class Activity1 : Activity, Android.Support.V4.View.ViewPager.IOnPageChangeListener
{
public Android.Support.V4.View.ViewPager vPager;
public void OnPageSelected(int page)
{
vPager.AddView(new FragmentTab1().View);
}
public void OnPageScrollStateChanged(int a)
{
}
public void OnPageScrolled(int a, float b, int c)
{
}
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
vPager = new Android.Support.V4.View.ViewPager(this);
vPager.SetOnPageChangeListener(this);
FrameLayout fl = FindViewById<FrameLayout>(Resource.Id.frameLayout1);
fl.AddView(vPager);
//TABS
ActionBar.Tab tab1 = ActionBar.NewTab();
tab1.SetText("Tab 1");
tab1.TabSelected += delegate(object sender,ActionBar.TabEventArgs e)
{
vPager.SetCurrentItem(tab1.Position, true);
//e.FragmentTransaction.Add(Resource.Id.frameLayout1, new FragmentTab1());
};
ActionBar.Tab tab2 = ActionBar.NewTab();
tab2.SetText("Tab 2");
tab2.TabSelected += delegate(object sender, ActionBar.TabEventArgs e)
{
vPager.SetCurrentItem(tab1.Position, true);
// e.FragmentTransaction.Add(Resource.Id.frameLayout1, new FragmentTab2());
};
this.ActionBar.AddTab(tab1);
this.ActionBar.AddTab(tab2);
}
}