本文整理汇总了C#中ViewPager.AddOnPageChangeListener方法的典型用法代码示例。如果您正苦于以下问题:C# ViewPager.AddOnPageChangeListener方法的具体用法?C# ViewPager.AddOnPageChangeListener怎么用?C# ViewPager.AddOnPageChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewPager
的用法示例。
在下文中一共展示了ViewPager.AddOnPageChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: MovieViewHolder
public MovieViewHolder (View itemView, MoviesRecyeclerAdapter parentAdapter) : base (itemView)
{
_context = itemView.Context;
this.parentAdapter = parentAdapter;
viewPager = itemView.FindViewById<ViewPager> (Resource.Id.viewPager).JavaCast<ViewPager> ();
adapter = new ValuePagerAdapter (itemView.Context);
viewPager.Adapter = adapter;
viewPager.AddOnPageChangeListener (this);
viewPager.SetCurrentItem (1, false);
}
示例3: OnCreate
protected async override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Bootstrapper.Initialize();
ViewModel = Resolver.Resolve<MainViewModel>();
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
_viewPager = FindViewById<ViewPager>(Resource.Id.pager);
var adapter = new FragmentPagerAdapter(SupportFragmentManager);
adapter.Add(new ViewPagerFragment(((i, v, b) =>
{
_shl = new ListView(this);
var layout = new LinearLayout(this);
layout.AddView(_shl);
return layout;
})));
adapter.Add(new ViewPagerFragment(((i, v, b) =>
{
_ha = new ListView(this);
var layout = new LinearLayout(this);
layout.AddView(_ha);
return layout;
})));
ViewModel.PropertyChanged += ViewModel_PropertyChanged;
ViewModel.Initialize();
_viewPager.Adapter = adapter;
_viewPager.AddOnPageChangeListener(this);
var tab1 = ActionBar.NewTab();
tab1.SetText("SHL");
tab1.TabSelected += Tab_TabSelected;
var tab2 = ActionBar.NewTab();
tab2.SetText("Hockeyallsvenskan");
tab2.TabSelected += Tab_TabSelected;
ActionBar.AddTab(tab1);
ActionBar.AddTab(tab2);
}
示例4: InitViews
private void InitViews()
{
LayoutInflater inflater = LayoutInflater.From (this);
//初始化引导图片列表
views = new List<View>();
views.Add (inflater.Inflate (Resource.Layout.Guider1, null));
views.Add (inflater.Inflate(Resource.Layout.Guider2,null));
views.Add (inflater.Inflate(Resource.Layout.Guider3,null));
views.Add (inflater.Inflate(Resource.Layout.Guider4,null));
vpAdapter = new GuiderViewPageAdapter (views, this);
guiderViewpager = FindViewById<ViewPager> (Resource.Id.guiderviewpager);
guiderViewpager.Adapter = vpAdapter;
//绑定回调
guiderViewpager.AddOnPageChangeListener (this);
}
示例5: SetViewPager
public void SetViewPager(ViewPager view)
{
if (_viewPager == view) return;
if (null != _viewPager)
_viewPager.ClearOnPageChangeListeners();
if (null == view.Adapter)
throw new InvalidOperationException("ViewPager does not have an Adapter instance.");
_viewPager = view;
_viewPager.AddOnPageChangeListener(this);
NotifyDataSetChanged();
}
示例6: SetUpTabLayout
private void SetUpTabLayout(View v)
{
string[] myTitles =
{
"Overview"
, "Up Next"
, "Seasons"
};
_adapter = new EpisodeManagerAdapter(Activity.SupportFragmentManager, myTitles, _myShow);
_pager = v.FindViewById<ViewPager>(Resource.Id.pager);
_tabs = v.FindViewById<TabLayout>(Resource.Id.tabs);
_pager.Adapter = _adapter;
_pager.AddOnPageChangeListener(this);
_tabs.SetupWithViewPager(_pager);
var pageMargin = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 4, Resources.DisplayMetrics);
_pager.PageMargin = pageMargin;
_pager.CurrentItem = selectedTab;
_tabs.SetOnTabSelectedListener(this);
}
示例7: OnFinishInflate
protected override void OnFinishInflate()
{
base.OnFinishInflate();
//add @layout/material_view_pager_layout as child, containing all the MaterialViewPager views
AddView(LayoutInflater.From(Context).Inflate(Resource.Layout.material_view_pager_layout, this, false));
_headerBackgroundContainer = FindViewById<ViewGroup>(Resource.Id.headerBackgroundContainer);
_pagerTitleStripContainer = FindViewById<ViewGroup>(Resource.Id.pagerTitleStripContainer);
_logoContainer = FindViewById<ViewGroup>(Resource.Id.logoContainer);
MToolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
if (Settings.DisableToolbar)
MToolbar.Visibility = ViewStates.Invisible;
MViewPager = FindViewById<ViewPager>(Resource.Id.viewPager);
MViewPager.AddOnPageChangeListener(this);
//inflate subviews defined in attributes
{
int headerId = Settings.HeaderLayoutId;
if (headerId == -1)
{
headerId = Settings.AnimatedHeaderImage ? Resource.Layout.material_view_pager_moving_header : Resource.Layout.material_view_pager_imageview_header;
}
_headerBackgroundContainer.AddView(LayoutInflater.From(Context).Inflate(headerId, _headerBackgroundContainer, false));
}
if (IsInEditMode)
{ //preview titlestrip
//add fake tabs on edit mode
Settings.PagerTitleStripId = Resource.Layout.tools_material_view_pager_pagertitlestrip;
}
if (Settings.PagerTitleStripId != -1)
{
_pagerTitleStripContainer.AddView(LayoutInflater.From(Context).Inflate(Settings.PagerTitleStripId, _pagerTitleStripContainer, false));
}
if (Settings.LogoLayoutId != -1)
{
_logoContainer.AddView(LayoutInflater.From(Context).Inflate(Settings.LogoLayoutId, _logoContainer, false));
if (Settings.LogoMarginTop != 0)
{
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)_logoContainer.LayoutParameters;
layoutParams.SetMargins(0, Settings.LogoMarginTop, 0, 0);
_logoContainer.LayoutParameters = layoutParams;
}
}
HeaderBackground = FindViewById(Resource.Id.headerBackground);
ToolbarLayoutBackground = FindViewById(Resource.Id.toolbar_layout_background);
InitialiseHeights();
//construct the materialViewPagerHeader with subviews
if (!IsInEditMode)
{
MaterialViewPagerHeader = MaterialViewPagerHeader
.WithToolbar(MToolbar)
.WithToolbarLayoutBackground(ToolbarLayoutBackground)
.WithPagerSlidingTabStrip(_pagerTitleStripContainer)
.WithHeaderBackground(HeaderBackground)
.WithStatusBackground(FindViewById(Resource.Id.statusBackground))
.WithLogo(_logoContainer);
//and construct the MaterialViewPagerAnimator
//attach it to the activity to enable MaterialViewPagerHeaderView.setMaterialHeight();
MaterialViewPagerHelper.Register(Context, new MaterialViewPagerAnimator(this));
}
else
{
//if in edit mode, add fake cardsviews
View sample = LayoutInflater.From(Context).Inflate(Resource.Layout.tools_list_items, _pagerTitleStripContainer, false);
LayoutParams param = (LayoutParams)sample.LayoutParameters;
int marginTop = (int)Math.Round(Utils.DpToPx(Settings.HeaderHeight + 10, Context));
param.SetMargins(0, marginTop, 0, 0);
LayoutParameters = param;
AddView(sample);
}
}
示例8: InitViewPager
private void InitViewPager() {
adviceViewPager = (ViewPager) FindViewById<ViewPager>(Resource.Id.adviceViewPager);
fragmentsList = new List<Android.Support.V4.App.Fragment>();
_writeAdviceFrag = new WriteAdviceFragment();
_recordAdviceFrag = new RecordAdviceFragment();
fragmentsList.Add(_writeAdviceFrag);
fragmentsList.Add(_recordAdviceFrag);
//关闭预加载,默认一次只加载一个Fragment
adviceViewPager.OffscreenPageLimit =1;
adviceViewPager.Adapter = new ViewFragmentPagerAdapter(fragmentsList,SupportFragmentManager);
adviceViewPager.AddOnPageChangeListener (this);
adviceViewPager.SetCurrentItem (0, true);
}
示例9: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
view_pager = (FindViewById<ViewPager> (Resource.Id.pager));
//make the first page the white light fragment
LightFragmentAdapter adapter = new LightFragmentAdapter (SupportFragmentManager);
adapter.AddFragment (new WhiteLightFragment ());
//make the second page the party light fragment
party_fragment = new PartyLightFragment ();
adapter.AddFragment (party_fragment);
view_pager.Adapter = adapter;
view_pager.AddOnPageChangeListener(new MyOnPageListener (this));
}
示例10: SetUpTabLayout
private void SetUpTabLayout()
{
string[] myTitles =
{
"Popular"
, "Action"
, "SciFi"
, "Drama"
, "Mystery"
};
_adapter = new AddShowPagerAdapter(SupportFragmentManager, myTitles, this);
_pager = FindViewById<ViewPager>(Resource.Id.pager);
_tabs = FindViewById<TabLayout>(Resource.Id.tabs);
_pager.Adapter = _adapter;
_pager.AddOnPageChangeListener(this);
_tabs.SetupWithViewPager(_pager);
var pageMargin = (int) TypedValue.ApplyDimension(ComplexUnitType.Dip, 4, Resources.DisplayMetrics);
_pager.PageMargin = pageMargin;
_pager.CurrentItem = 0;
_tabs.SetOnTabSelectedListener(this);
}
示例11: SetViewPager
public void SetViewPager(ViewPager view)
{
if (view.Adapter == null)
{
//throw new IllegalStateException ("ViewPager does not have adapter instance.");
}
mViewPager = view;
mViewPager.AddOnPageChangeListener(this);//SetOnPageChangeListener (this);
UpdatePageSize();
Invalidate();
}
示例12: InitView
private void InitView( ) {
btnTabmyGuardian = View.FindViewById<Button>(Resource.Id.btn_tab_myGuardian);
btnTabotherGuardian = View.FindViewById<Button>(Resource.Id.btn_tab_otherGuardian);
btnTabmyGuardian.SetTextColor(Resources.GetColor(Resource.Color.blue));
btnTabmyGuardian.SetOnClickListener(this);
btnTabotherGuardian.SetOnClickListener(this);
//设置viewpager
guardianViewPager = (ViewPager) View.FindViewById<ViewPager>(Resource.Id.guardianViewpager);
fragmentsList = new List<Fragment>();
_myGuardianFrag = new MyGuardianFrag();
_otherGuardianFrag = new OtherGuardianFrag();
fragmentsList.Add(_myGuardianFrag);
fragmentsList.Add(_otherGuardianFrag);
//关闭预加载,默认一次只加载一个Fragment
guardianViewPager.OffscreenPageLimit =1;
guardianViewPager.Adapter = new ViewFragmentPagerAdapter(fragmentsList,ChildFragmentManager);
guardianViewPager.AddOnPageChangeListener (this);
guardianViewPager.SetCurrentItem (0, true);
ll_actionBar = View.FindViewById<LinearLayout> (Resource.Id.ll_actionBar);
//弹出popupwindow,绑定监护人和监护人申请
btn_bindGuardian = View.FindViewById<Button> (Resource.Id.btn_BindGuardian);
btn_bindGuardian.Click += (sender, e) =>
{
BackgroundAlpha(0.5f);
if(guardianPopupWindow!=null)
guardianPopupWindow.ShowAsDropDown(ll_actionBar,-100,1,GravityFlags.Right|GravityFlags.Top);
else
{
InitPopupWindow();
}
};
}
示例13: setUpTabLayout
void setUpTabLayout ()
{
string[] myTitles = {
//"Search",
"Popular"
, "Comedy"
, "Action","Drama"
//, "Mystery", "SciFi", "Animation"
};
_adapter = new AddShowsPagerAdapter (this.SupportFragmentManager, myTitles, _trakkedShowsEnumerable);
_pager = FindViewById<ViewPager> (Resource.Id.pager);
_tabs = FindViewById<TabLayout> (Resource.Id.tabs);
_pager.Adapter = _adapter;
_pager.AddOnPageChangeListener(this);
_tabs.SetupWithViewPager (_pager);
var pageMargin = (int)TypedValue.ApplyDimension (ComplexUnitType.Dip, 4, Resources.DisplayMetrics);
_pager.PageMargin = pageMargin;
_pager.CurrentItem = _tabPosition;
_tabs.SetOnTabSelectedListener (this);
ChangeTab(_tabPosition);
RetrieveTrakkedShows();
}
示例14: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView (Resource.Layout.activity_main);
var application = (AnalyticsApplication)Application;
mTracker = application.DefaultTracker;
mImagePagerAdapter = new ImagePagerAdapter (this, SupportFragmentManager, ImageInfos.ToArray());
mViewPager = FindViewById<ViewPager> (Resource.Id.pager);
mViewPager.Adapter = mImagePagerAdapter;
mViewPager.AddOnPageChangeListener (new SimpleOnPageChangeListener (this));
SendScreenImageName ();
}
示例15: SetViewPager
public void SetViewPager(ViewPager view)
{
if (_viewPager == view) return;
if (null != _viewPager)
_viewPager.ClearOnPageChangeListeners();
if (null == view.Adapter)
throw new InvalidOperationException("ViewPager does not have an Adapter instance.");
_viewPager = view;
_viewPager.AddOnPageChangeListener(this);
Invalidate();
Post(_fadeRunnable);
}