protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.SetContentView(Resource.Layout.MainActivity); // Create the adapter that will return a fragment for each of the three primary sections // of the app. this._navSectionsPagerAdapter = new ListNavSectionsPagerAdapter(this.SupportFragmentManager); // Set up the action bar. var actionBar = this.ActionBar; // Specify that the Home button should show an "Up" caret, indicating that touching the // button will take the user one step up in the application's hierarchy. actionBar.SetDisplayHomeAsUpEnabled(true); // Specify that we will be displaying list in the action bar. actionBar.NavigationMode = ActionBarNavigationMode.List; var titles = new string[this._navSectionsPagerAdapter.Count]; for (var i = 0; i < titles.Length; i++) { titles[i] = this._navSectionsPagerAdapter.GetPageTitle(i); } actionBar.SetListNavigationCallbacks( new ArrayAdapter( actionBar.ThemedContext, Resource.Layout.ListNavigationActivityActionbarListItem, Android.Resource.Id.Text1, titles ), this ); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. this._viewPager = this.FindViewById <ViewPager>(Resource.Id.Pager); this._viewPager.Adapter = this._navSectionsPagerAdapter; // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. this._viewPager.PageSelected += delegate(object sender, ViewPager.PageSelectedEventArgs e) { actionBar.SetSelectedNavigationItem(e.P0); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.SetContentView(Resource.Layout.MainActivity); // Create the adapter that will return a fragment for each of the three primary sections // of the app. this._navSectionsPagerAdapter = new ListNavSectionsPagerAdapter(this.SupportFragmentManager); // Set up the action bar. var actionBar = this.ActionBar; // Specify that the Home button should show an "Up" caret, indicating that touching the // button will take the user one step up in the application's hierarchy. actionBar.SetDisplayHomeAsUpEnabled(true); // Specify that we will be displaying list in the action bar. actionBar.NavigationMode = ActionBarNavigationMode.List; var titles = new string[this._navSectionsPagerAdapter.Count]; for (var i = 0; i < titles.Length; i++) { titles[i] = this._navSectionsPagerAdapter.GetPageTitle(i); } actionBar.SetListNavigationCallbacks( new ArrayAdapter( actionBar.ThemedContext, Resource.Layout.ListNavigationActivityActionbarListItem, Android.Resource.Id.Text1, titles ), this ); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. this._viewPager = this.FindViewById<ViewPager>(Resource.Id.Pager); this._viewPager.Adapter = this._navSectionsPagerAdapter; // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. this._viewPager.PageSelected += delegate(object sender, ViewPager.PageSelectedEventArgs e) { actionBar.SetSelectedNavigationItem(e.P0); }; }