本文整理汇总了C#中ViewPager.SetCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:C# ViewPager.SetCurrentItem方法的具体用法?C# ViewPager.SetCurrentItem怎么用?C# ViewPager.SetCurrentItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewPager
的用法示例。
在下文中一共展示了ViewPager.SetCurrentItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState);
SetContentView(R.Layouts.fragment_pager);
mAdapter = new MyAdapter(GetSupportFragmentManager());
mPager = (ViewPager)FindViewById(R.Ids.pager);
mPager.SetAdapter(mAdapter);
// Watch for button clicks.
Button button = (Button)FindViewById(R.Ids.goto_first);
button.Click += (o,a) => mPager.SetCurrentItem(0);
button = (Button)FindViewById(R.Ids.goto_last);
button.Click += (o,a) => mPager.SetCurrentItem(NUM_ITEMS-1);
}
示例2: 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;
}
示例3: 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);
}
示例4: 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;
}
}
}
示例5: 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);
}
示例6: 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);
}
示例7: AssignButtonFunction
private void AssignButtonFunction(RecipeStepTimerHandler t, Button button, ViewPager vp)
{
//ViewGroup timerFrame = t.getTimerFrame ();
button.Click += delegate {
if (t.IsActive ()) {
DeactivateTimer(t, button);
} else {
ActivateTimer(t, button);
//ViewPager vp = ((StepsActivity)Activity).GetViewPager();
int pos = vp.CurrentItem + 1;
vp.SetCurrentItem (pos, true);
/*t.StartTimer ();
button.SetText (Resource.String.pause);
timerFrame.Visibility = ViewStates.Visible;*/
}
};
}
示例8: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
pager = FindViewById<ViewPager>(Resource.Id.myviewpager);
adapter = new MyPagerAdapter(this, this.SupportFragmentManager);
pager.Adapter = adapter;
pager.SetOnPageChangeListener (adapter);
pager.SetCurrentItem (FIRST_PAGE,true);
pager.OffscreenPageLimit = 3;
pager.PageMargin = Convert.ToInt32 (GetString(Resource.String.pagermargin));
}
示例9: OnElementChanged
protected override void OnElementChanged (ElementChangedEventArgs<TabbedPage> e)
{
base.OnElementChanged (e);
tabbedPage = e.NewElement as PrettyTabbedPage;
viewPager = (ViewPager)GetChildAt (0);
tabs = this.FindViewById<TabLayout> (Resource.Id.sliding_tabs);
tabs.TabSelected+=(s,a)=>{
var page=tabbedPage.Children [a.Tab.Position];
if(page is TabPage)
{
var tPage =(TabPage)page;
SetTab(a.Tab,tPage.SelectedIcon.File);
}
viewPager.SetCurrentItem(a.Tab.Position,false);
};
tabs.TabUnselected += (s, a) => {
var page=tabbedPage.Children [a.Tab.Position];
if(page is TabPage)
{
SetTab(a.Tab,page.Icon.File);
}
};
}
示例10: InitViewPager
private void InitViewPager() {
alarmViewPager = (ViewPager) View.FindViewById<ViewPager>(Resource.Id.alarmViewPager);
fragmentsList = new List<Fragment>();
_myAlarmFrag = new MyAlarmFrag();
_otherAlarmFrag = new OtherAlarmFrag();
fragmentsList.Add(_myAlarmFrag);
fragmentsList.Add(_otherAlarmFrag);
//关闭预加载,默认一次只加载一个Fragment
alarmViewPager.OffscreenPageLimit =1;
alarmViewPager.Adapter = new ViewFragmentPagerAdapter(fragmentsList,ChildFragmentManager);
alarmViewPager.AddOnPageChangeListener (this);
alarmViewPager.SetCurrentItem (0, true);
}
示例11: 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);
}
示例12: OnCreate
//Called when the page is created
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
int mealId = Intent.GetIntExtra ("mealId", 0);
Console.WriteLine ("Recipe Id: " + mealId);
SetContentView (Resource.Layout.Walkthrough);
vp = FindViewById<ViewPager> (Resource.Id.walkthrough_pager);
//Store pointers to timer frames to be referenced by the fragments
timerFrames = new ViewGroup[5];
timerFrames [0] = (ViewGroup) FindViewById (Resource.Id.walkthrough_frame_1);
timerFrames [1] = (ViewGroup) FindViewById (Resource.Id.walkthrough_frame_2);
timerFrames [2] = (ViewGroup) FindViewById (Resource.Id.walkthrough_frame_3);
timerFrames [3] = (ViewGroup) FindViewById (Resource.Id.walkthrough_frame_4);
timerFrames [4] = (ViewGroup) FindViewById (Resource.Id.walkthrough_frame_5);
timerPoolHandler = new TimerPoolHandler (timerFrames);
//TODO fix
steps = WebUtils.getRecipeSteps (mealId);
fragmentCount = steps.Length + 1;
vp.Adapter = new StepFragmentPagerAdapter (SupportFragmentManager, steps, timerPoolHandler);
//Set up the progress dots to appear at the bottom of the screen
ViewGroup pd = (ViewGroup) FindViewById (Resource.Id.walkthrough_progress_dots);
NavDot[] progressDots = new NavDot[fragmentCount];
Drawable open = Resources.GetDrawable (Resource.Drawable.circle_open);
for (int i = 0; i < progressDots.Length; i++) {
NavDot dot = new NavDot (this);
dot.SetMaxWidth(30);
dot.SetImageDrawable (open);
pd.AddView (dot);
dot.Num = i;
dot.Click += delegate {
Console.WriteLine("Going to page " + dot.Num);
vp.SetCurrentItem (dot.Num, true);
};
progressDots [i] = dot;
}
progressDots[0].SetImageDrawable (Resources.GetDrawable(Resource.Drawable.circle_closed));
ViewGroup pbs = (ViewGroup)FindViewById (Resource.Id.walkthrough_progress_bars);
vp.AddOnPageChangeListener (new StepChangeListener (progressDots, open, Resources.GetDrawable(Resource.Drawable.circle_closed), pbs));
}
示例13: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView(Resource.Layout.ScrollImages);
var position = Intent.GetIntExtra(POSITION, 0);
viewPager = FindViewById<ViewPager>(Resource.Id.pager);
viewPager.SetClipToPadding(false);
//viewPager.PageMargin = DimensionHelper.DpToPx(12);
//More documentation is available on this page
//https://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-26-Retrieving-a-Photo-from-Flickrs-API
string[] licenses = { "4", "5", "6", "7" };
string license = String.Join(",", licenses);
license = license.Replace(",", "%2C");
string url = "https://api.flickr.com/services/rest/" +
"?method=flickr.photos.search" +
"&api_key={0}" +
"&user_id={1}" +
"&format=json" +
"&page={2}" +
"&per_page={3}" +
"&nojsoncallback=1";
var baseUrl = string.Format(url,
ImageConfig.flickrApiKey,
ImageConfig.userId,
ImageConfig.page,
ImageConfig.per_page);
var client = new System.Net.Http.HttpClient ();
client.GetStringAsync (baseUrl).ContinueWith ((requestString) => {
var flickrResult = requestString.Result;
FlickrData apiData = JsonConvert.DeserializeObject<FlickrData>(flickrResult);
int counter = 0;
if (apiData.stat == "ok")
{
foreach (Photo data in apiData.photos.photo)
{
// To retrieve one photo, use this format:
//http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}{size}.jpg
counter = counter+1;
string photoUrl = "https://farm{0}.staticflickr.com/{1}/{2}_{3}_{4}.jpg";
string largeFlickrUrl = string.Format(photoUrl,data.farm,data.server,data.id,data.secret,"b");
string name = string.Format("Image{0}", counter);
items.Add(new ScrollImages(){Images=largeFlickrUrl , Activity=this});
}
}
viewPager.Adapter = new SwipeGalleryStateAdapter(SupportFragmentManager, items);
viewPager.SetCurrentItem(position, false);
});
}
示例14: 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();
}
};
}
示例15: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
IsFirstInitialization = true;
_persoon = Gegevens.GetPerson();
_groep = Gegevens.CurrentGroup();
SetContentView(Resource.Layout.Hoofdscherm);
_toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
_totalDebt = _toolbar.FindViewById<TextView>(Resource.Id.TotalDebt);
_title = _toolbar.FindViewById<TextView>(Resource.Id.Title);
_title.Text = _persoon.Id;
TotalDebt = _persoon.TotaalSchuld();
SetSupportActionBar(_toolbar);
SupportActionBar.Title = "";
_fragments = new HoofdschermFragment[]
{
new SessionFragment(),
new PayFragment(),
new ContactFragment()
};
var titles = CharSequence.ArrayFromStringArray(new[]
{
"Sessions",
"Payments",
"Contacts"
});
_viewPager = FindViewById<ViewPager>(Resource.Id.viewpager);
_viewPager.Adapter = new TabsFragmentPagerAdapter(SupportFragmentManager, _fragments, titles);
_viewPager.SetCurrentItem(1, true);
_tabLayout = FindViewById<TabLayout>(Resource.Id.sliding_tabs);
_tabLayout.SetupWithViewPager(_viewPager);
_tabLayout.SetOnTabSelectedListener(this);
}