• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ViewPager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ViewPager的典型用法代码示例。如果您正苦于以下问题:C# ViewPager类的具体用法?C# ViewPager怎么用?C# ViewPager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ViewPager类属于命名空间,在下文中一共展示了ViewPager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
开发者ID:huguodong,项目名称:XamandroidSupportDesign22.2.0.0,代码行数:35,代码来源:MainActivity.cs


示例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);
        }
开发者ID:anhvule,项目名称:ParallaxViewPager.XamarinAndroid,代码行数:26,代码来源:MainActivity.cs


示例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);
        }
开发者ID:fitzhex,项目名称:testrepo,代码行数:26,代码来源:MainActivity.cs


示例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 ();
        }
开发者ID:tamifist,项目名称:KinderChat,代码行数:33,代码来源:MainActivity.cs


示例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);

		}
开发者ID:kktanpiya,项目名称:kimuraHazuki048,代码行数:30,代码来源:MainActivity.cs


示例6: MainTabStatePagerAdapter

 public MainTabStatePagerAdapter(FragmentManager fm, ViewPager viewPager)
     : base(fm)
 {
     _fragmentManager = fm;
     _fragments = new List<Tuple<MobileNavigationTabType, Fragment>>();
     _viewPager = viewPager;
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:7,代码来源:MainTabStatePagerAdapter.cs


示例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;
 }
开发者ID:John078,项目名称:INFDEV02-1_0907498,代码行数:7,代码来源:SlidingTabsFragment.cs


示例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);
        }
开发者ID:hugoterelle,项目名称:TestFragment,代码行数:26,代码来源:MainView.cs


示例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);
        }
开发者ID:AhmedWarreth,项目名称:MvxViewPager,代码行数:39,代码来源:HomeView.cs


示例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;
        }
开发者ID:anheru88,项目名称:TeLlevo-Xamarin,代码行数:29,代码来源:MainActivity.cs


示例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;
                }
            }
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:30,代码来源:CrimePagerActivity.cs


示例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;
        }
开发者ID:MilenPavlov,项目名称:Xam.NavDrawer,代码行数:35,代码来源:FriendsView.cs


示例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";

		}
开发者ID:ashokkumarreddy1987,项目名称:learnings,代码行数:31,代码来源:AutoImageScroller.cs


示例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);
	    }
开发者ID:okrotowa,项目名称:Mosigra.Yorsh,代码行数:7,代码来源:RulesActivity.cs


示例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;
        }
开发者ID:mamta-bisht,项目名称:SlidingMenuSharp,代码行数:27,代码来源:ViewPagerActivity.cs


示例16: OnCreateView

 public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
 {
     var view = inflater.Inflate(Resource.Layout.fragment_collection_demo, container, false);
     this._viewPager = view.FindViewById<ViewPager>(Resource.Id.fragment_collection_demo_viewpager);
     this._viewPager.Adapter = this._adapter;
     return view;
 }
开发者ID:Arlenxiao,项目名称:MonoDroid,代码行数:7,代码来源:CollectionDemoFragment.cs


示例17: 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);
			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;
			}

			SupportActionBar.SetDisplayHomeAsUpEnabled (false);
			SupportActionBar.SetHomeButtonEnabled (false);

		
			// Register for GCM
			KinderGcmService.Register (this);
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:26,代码来源:MainActivity.cs


示例18: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            //SetTheme(Resource.Style.Theme_Sherlock_Light);
            SetTheme(Resource.Style.Theme_Example);
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.IndeterminateProgress);
            SetSupportProgressBarIndeterminateVisibility(false);
            Sherlock.ActionBar.SetDisplayHomeAsUpEnabled(true);

            SetContentView(Resource.Layout.Main);
            // Show tabs
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            
            // attach adapter to the viewpager
            _pageAdapter = new ArtistPagerAdapter(SupportFragmentManager);
            _viewPager = FindViewById<ViewPager>(Resource.Id.myViewPager);
            _viewPager.Adapter = _pageAdapter;
            _viewPager.SetOnPageChangeListener(this);
            // startindex
            _viewPager.SetCurrentItem(0, true);

            var jsonArtist = Intent.GetStringExtra("Artist");
            _artist = JsonConvert.DeserializeObject<Artist>(jsonArtist);
            var jsonTopTracks = Intent.GetStringExtra("TopTracks");
            _topTracks = JsonConvert.DeserializeObject<TopTracks>(jsonTopTracks);
            var jsonTopAlbums = Intent.GetStringExtra("TopAlbums");
            _topAlbums = JsonConvert.DeserializeObject<TopAlbums>(jsonTopAlbums);

            _bitmapExtension = new BitmapExtension();
            try
            {
                _imageBitmap = _bitmapExtension.GetImageBitmapFromUrl(_artist.GetImageUrlOfSize("large"));
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Error: " + ex.Message, ToastLength.Short).Show();
            }

            //TABS
            var tab1 = Sherlock.ActionBar.NewTab();
            tab1.SetText("Artist");
            tab1.SetTabListener(this);

            var tab2 = Sherlock.ActionBar.NewTab();
            tab2.SetText("Similar Artists");
            tab2.SetTabListener(this);

            var tab3 = Sherlock.ActionBar.NewTab();
            tab3.SetText("Top 15 Tracks");
            tab3.SetTabListener(this);

            var tab4 = Sherlock.ActionBar.NewTab();
            tab4.SetText("Top 5 Albums");
            tab4.SetTabListener(this);

            Sherlock.ActionBar.AddTab(tab1);
            Sherlock.ActionBar.AddTab(tab2);
            Sherlock.ActionBar.AddTab(tab3);
            Sherlock.ActionBar.AddTab(tab4);
        }
开发者ID:jonteho,项目名称:last.fm-appcrossplat,代码行数:60,代码来源:ArtistActivity.cs


示例19: SessionsFragmentBinding

 private SessionsFragmentBinding(LayoutInflater inflater, ViewGroup root, bool attachToRoot)
 {
     Root = inflater.Inflate(Resource.Layout.fragment_sessions, root, attachToRoot);
     viewPager = Root.FindViewById<ViewPager>(Resource.Id.view_pager);
     tabLayout = Root.FindViewById<TabLayout>(Resource.Id.tab_layout);
     emptyViewButton = Root.FindViewById<AppCompatButton>(Resource.Id.empty_view_button);
     emptyView = Root.FindViewById<View>(Resource.Id.empty_view);
 }
开发者ID:nepula-h-okuyama,项目名称:DroidKaigi2016Xamarin,代码行数:8,代码来源:SessionsFragmentBinding.cs


示例20: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            vp = FindViewById<ViewPager>(Resource.Id.viewPager);
            vp.Adapter = new MyFragmentAdapter(SupportFragmentManager);
        }
开发者ID:vladasp,项目名称:XamarinTest,代码行数:8,代码来源:MainActivity.cs



注:本文中的ViewPager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ViewType类代码示例发布时间:2022-05-24
下一篇:
C# ViewModels类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap