本文整理汇总了C#中ViewPager类的典型用法代码示例。如果您正苦于以下问题:C# ViewPager类的具体用法?C# ViewPager怎么用?C# ViewPager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ViewPager类属于命名空间,在下文中一共展示了ViewPager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
var toolbar = FindViewById<V7Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
if (navigationView != null)
setupDrawerContent(navigationView);
navigationView.SetNavigationItemSelectedListener(this);
viewPager = FindViewById<Android.Support.V4.View.ViewPager>(Resource.Id.viewpager);
if (viewPager != null)
setupViewPager(viewPager);
var fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
fab.Click += (sender, e) =>
{
// Show a snackbar
Snackbar.Make(fab, "Here's a snackbar!", Snackbar.LengthLong).SetAction("Action",
v =>
Toast.MakeText(this, "Action", ToastLength.Short).Show()
).Show();
};
var tabLayout = FindViewById<TabLayout>(Resource.Id.tabs);
tabLayout.SetupWithViewPager(viewPager);
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.MainMenuForGuest);
_context = this;
_pager = FindViewById<ViewPager>(Resource.Id.pager);
_adapter = new ViewPagerAdapter(this, FragmentManager);
_pager.SetPageTransformer(true, new ParallaxPageTransformer());
_pager.Adapter = _adapter;
_adapter.ViewPager = _pager;
ViewPagerChangeListener pageChangeListener = new ViewPagerChangeListener(_pager, delegate(int position, int positionOffsetPixels)
{
// Write something
});
_pager.AddOnPageChangeListener(pageChangeListener);
_adapter.Campaigns = ItemFactory.Create();
_pager.SetCurrentItem(1, false);
}
示例3: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
adapter = new MyPagerAdapter(SupportFragmentManager);
pager = FindViewById<ViewPager> (Resource.Id.pager);
tabs = FindViewById<PagerSlidingTabStrip> (Resource.Id.tabs);
pager.Adapter = adapter;
tabs.Visibility = ViewStates.Invisible;
tabs.SetViewPager (pager);
var pageMargin = (int)TypedValue.ApplyDimension (ComplexUnitType.Dip, 4, Resources.DisplayMetrics);
pager.PageMargin = pageMargin;
tabs.OnPageChangeListener = this;
PageIndicator mIndicator = FindViewById<CirclePageIndicator> (Resource.Id.indicator);
mIndicator.SetViewPager (pager);
mIndicator.SetOnPageChangeListener (new MyPageChangeListener (this));
// timer.Elapsed+=timer_Elapsed;
// timer.Start();
SupportActionBar.SetDisplayHomeAsUpEnabled(false);
SupportActionBar.SetHomeButtonEnabled(false);
}
示例4: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate(bundle);
adapter = new MyPagerAdapter(this, SupportFragmentManager);
pager = FindViewById<ViewPager>(Resource.Id.pager);
tabs = FindViewById<PagerSlidingTabStrip>(Resource.Id.tabs);
tabs.SetBackgroundResource (Settings.AppTheme == AppTheme.Red ? Resource.Drawable.red_gradient : Resource.Drawable.blue_gradient);
pager.Adapter = adapter;
tabs.SetViewPager(pager);
tabs.OnPageChangeListener = this;
var pageMargin = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 4, Resources.DisplayMetrics);
pager.PageMargin = pageMargin;
pager.OffscreenPageLimit = 4;
if (Settings.FirstRun)
{
pager.CurrentItem = 2;
App.MessageDialog.SendMessage(Resources.GetString(Resource.String.get_started_welcome),
Resources.GetString(Resource.String.welcome_to_kinderchat));
}
else
{
pager.CurrentItem = 0;
}
//IntentFilter connectivityIntentFilter = new IntentFilter();
//connectivityIntentFilter.AddAction(Android.Net.ConnectivityManager.ConnectivityAction);
//RegisterReceiver(new NetworkChangeReceiver(), connectivityIntentFilter);
// Register for GCM
KinderGcmService.Register(this);
App.ConnectionManager.TryKeepConnectionAsync ();
}
示例5: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.MyHealth_Main);
//toolbar = (Toolbar)FindViewById (Resource.Id.tool_bar);
//SetActionBar (toolbar);
/*listData = new ListDataHolder ();
recyclerView = FindViewById <RecyclerView> (Resource.Id.recyclerView);
mLayoutManager = new LinearLayoutManager (this);
recyclerView.SetLayoutManager (mLayoutManager);
recyclerAdapter = new RecyclerViewAdapter (this, listData);
recyclerView.SetAdapter (recyclerAdapter);*/
adapter = new MyHealth_ViewPagerAdapter (SupportFragmentManager);
pager = FindViewById <ViewPager> (Resource.Id.pager);
pager.Adapter = adapter;
tabs = FindViewById<MyHealth_SlidingTabScrollView> (Resource.Id.tabs);
tabs.ViewPager = pager;
toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.app_bar);
toolbar.SetBackgroundColor (Color.ParseColor ("#009688"));
SetSupportActionBar (toolbar);
}
示例6: MainTabStatePagerAdapter
public MainTabStatePagerAdapter(FragmentManager fm, ViewPager viewPager)
: base(fm)
{
_fragmentManager = fm;
_fragments = new List<Tuple<MobileNavigationTabType, Fragment>>();
_viewPager = viewPager;
}
示例7: OnViewCreated
public override void OnViewCreated(View view, Bundle savedInstaneState)
{
mSlidingTabScrollView = view.FindViewById<SlidingTabScrollView>(Resource.Id.sliding_tabs);
mViewPager = view.FindViewById<ViewPager>(Resource.Id.viewpager);
mViewPager.Adapter = new SamplePagerAdapter();
mSlidingTabScrollView.ViewPager = mViewPager;
}
示例8: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
_fragments = new List<MvxFragmentWithTitle>
{
new Tab1Fragment(),
new Tab2Fragment(),
new Tab3Fragment(),
new Tab3Fragment(),
new Tab3Fragment(),
new Tab3Fragment(),
new Tab3Fragment(),
new Tab3Fragment()
};
_adapter = new FragmentTextAdapter(SupportFragmentManager, _fragments);
_pager = FindViewById<ViewPager>(Resource.Id.pager);
_pager.Adapter = _adapter;
_indicator = FindViewById<TitlePageIndicator>(Resource.Id.indicator);
_indicator.SetViewPager(_pager);
}
示例9: OnCreate
/// <summary>
/// Called when [create].
/// </summary>
/// <param name="bundle">The bundle.</param>
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.SetContentView(Resource.Layout.HomeView);
var fragments = new List<MvxViewPagerFragmentAdapter.FragmentInfo>
{
new MvxViewPagerFragmentAdapter.FragmentInfo
{
FragmentType = typeof(FirstFragment),
Title = "First Fragment",
ViewModel = ViewModel.First
},
new MvxViewPagerFragmentAdapter.FragmentInfo
{
FragmentType = typeof(SecondFragment),
Title = "Second Fragment",
ViewModel = ViewModel.Second
},
new MvxViewPagerFragmentAdapter.FragmentInfo
{
FragmentType = typeof(ThirdFragment),
Title = "Third Fragment",
ViewModel = ViewModel.Third
}
};
_viewPager = FindViewById<ViewPager>(Resource.Id.viewPager);
_adapter = new MvxViewPagerFragmentAdapter(this, SupportFragmentManager, fragments);
_viewPager.Adapter = _adapter;
_pageIndicator = FindViewById<PagerSlidingTabStrip>(Resource.Id.viewPagerIndicator);
_pageIndicator.SetViewPager(_viewPager);
}
示例10: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
this.fragments = new List<Android.App.Fragment>();
PagerFragment_1 pager1 = new PagerFragment_1 ();
//PagerFragment_2 pager2 = new PagerFragment_2 ();
//PagerFragment_3 pager3 = new PagerFragment_3 ();
//PagerFragment_4 pager4 = new PagerFragment_4 ();
//PagerFragment_5 pager5 = new PagerFragment_5 ();
//PagerFragment_6 pager6 = new PagerFragment_6 ();
this.fragments.Add (pager1);
//this.fragments.Add (pager2);
//this.fragments.Add (pager3);
//this.fragments.Add (pager4);
//this.fragments.Add (pager5);
//this.fragments.Add (pager6);
pagerAdapter = new PagerAdapter (this.FragmentManager, this.fragments);
viewPager = this.FindViewById<ViewPager> (Resource.Id.pager);
viewPager.Adapter = pagerAdapter;
}
示例11: OnCreate
protected override void OnCreate(Android.OS.Bundle savedInstanceState)
{
//RequestWindowFeature(Android.Views.WindowFeatures.ActionBar);
base.OnCreate(savedInstanceState);
CrimePagerActivity.context = this;
mViewPager = new ViewPager(this);
mViewPager.Id = (Resource.Id.viewPager);
SetContentView(mViewPager);
mCrimes = CrimeLab.GetInstance(CrimePagerActivity.context).Crimes;
Title = mCrimes[0].Title;
CrimePagerAdapter adapter = new CrimePagerAdapter(SupportFragmentManager);
mViewPager.Adapter = adapter;
mViewPager.PageSelected += (object sender, ViewPager.PageSelectedEventArgs e) => {
var crime = mCrimes[e.Position];
if (crime.Title != null)
Title = crime.Title;
};
// mViewPager.SetOnPageChangeListener(this);
string crimeId = Intent.GetStringExtra(CrimeFragment.EXTRA_CRIME_ID);
for (int i = 0; i < mCrimes.Count; i++) {
if (mCrimes[i].Id == crimeId) {
mViewPager.SetCurrentItem(i, false);
break;
}
}
}
示例12: OnCreateView
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState)
{
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
var view = this.BindingInflate(Resource.Layout.fragment_friends, null);
// Create your application here
this.m_ViewPager = view.FindViewById<ViewPager>(Resource.Id.viewPager);
this.m_ViewPager.OffscreenPageLimit = 4;
this.m_PageIndicator = view.FindViewById<TabPageIndicator>(Resource.Id.viewPagerIndicator);
var fragments = new List<MvxViewPagerFragmentAdapter.FragmentInfo>
{
new MvxViewPagerFragmentAdapter.FragmentInfo
{
FragmentType = typeof(FriendsAllView),
Title = "All",
ViewModel = this.ViewModel.FriendsAllViewModel
},
new MvxViewPagerFragmentAdapter.FragmentInfo
{
FragmentType = typeof(FriendsRecentView),
Title = "Recent",
ViewModel = this.ViewModel.FriendsRecentViewModel
}
};
this.m_Adapter = new MvxViewPagerFragmentAdapter(this.Activity, this.ChildFragmentManager, fragments);
this.m_ViewPager.Adapter = this.m_Adapter;
this.m_PageIndicator.SetViewPager(this.m_ViewPager);
this.m_PageIndicator.CurrentItem = 0;
return view;
}
示例13: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
itemData = new List<int> ();
itemData.Add (Resource.Drawable.photo1);
itemData.Add (Resource.Drawable.photo2);
itemData.Add (Resource.Drawable.photo3);
itemData.Add (Resource.Drawable.photo4);
imageValue = 0;
SetContentView(Resource.Layout.simple_circle_viewpager);
//Set up adapter with List of photo ID as item Data
_adapter = new FragStateSupport(SupportFragmentManager,itemData);
//Setup pager reference
_pager = FindViewById<ViewPager>(Resource.Id.pager);
_pager.Adapter = _adapter;
//Setup CirclePageIndicator Reference
_indicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
_indicator.SetViewPager(_pager);
btn = FindViewById<Button> (Resource.Id.myButton);
btn.Click += HandleClick;
btn.Text = "Run Slider";
}
示例14: ViewPagerOnPageScrollStateChanged
private void ViewPagerOnPageScrollStateChanged(object sender, ViewPager.PageScrollStateChangedEventArgs pageScrollStateChangedEventArgs)
{
var rulesCirle = Resources.GetStringArray(Resource.Array.RulesCirle);
var imageScrollId = Resources.GetIdentifier("rules_" + rulesCirle[_viewPager.CurrentItem] + "_sroll_page", "drawable", this.PackageName);
var imageScroll = FindViewById<ImageView>(Resource.Id.imageScroll);
imageScroll.SetImageResource(imageScrollId);
}
示例15: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var vp = new ViewPager(this)
{
Id = "VP".GetHashCode()
};
SetContentView(vp);
vp.PageSelected += (sender, args) =>
{
switch (args.P0)
{
case 0:
SlidingMenu.TouchModeAbove = TouchMode.Fullscreen;
break;
default:
SlidingMenu.TouchModeAbove = TouchMode.Margin;
break;
}
};
vp.Adapter = new ColorPagerAdapter(SupportFragmentManager);
vp.SetCurrentItem(0, true);
SlidingMenu.TouchModeAbove = TouchMode.Fullscreen;
}