public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { View container = View.Inflate(parent.Context, Resource.Layout.list_item_child, null); TextView txtGroupName = (TextView)container.FindViewById(Resource.Id.txtExampleName); ExampleFragment child = (ExampleFragment)this.GetChild(groupPosition, childPosition); txtGroupName.Text = child.Title(); return(container); }
public static ExampleFragment Create(int color) { var args = new Bundle(); args.PutInt(COLOR_KEY, color); var fragment = new ExampleFragment(); fragment.Arguments = args; return(fragment); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); IList <ExampleFragment> fragments; FragmentStackNavigationController navigationController = null; if (savedInstanceState == null) { fragments = Enumerable.Range(0, MainActivity.Colors.Length).Select(i => ExampleFragment.Create(i)).ToList(); navigationController = FragmentStackNavigationController.Create( Resource.Animation.enter_from_right, Resource.Animation.exit_to_left, Resource.Animation.enter_from_left, Resource.Animation.exit_to_right); navigationController.Push(fragments[0]); this.SupportFragmentManager .BeginTransaction() .Add(Resource.Id.NavigationControllerContainer, navigationController, NAVIGATION_CONTROLLER_TAG) .Commit(); } else { navigationController = (FragmentStackNavigationController)this.SupportFragmentManager.FindFragmentByTag(NAVIGATION_CONTROLLER_TAG); var frags = navigationController.Fragments.Cast <ExampleFragment>().ToList(); while (frags.Count < MainActivity.Colors.Length) { frags.Add(ExampleFragment.Create(frags.Count)); } fragments = frags.ToArray(); } for (int i = 0; i < fragments.Count - 1; i++) { var g = i + 1; fragments[i].Tapped += (sender, e) => { navigationController.Push(fragments[g]); }; } }