protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); this.SetContentView(Resource.Layout.activity_control); if(SupportActionBar != null && selectedControl != null) { SupportActionBar.Title = selectedControl.ControlName(); } this.expList = (ExpandableListView)this.FindViewById (Resource.Id.expListView); MoveIndicatorImage (); ExamplesAdapter ea = new ExamplesAdapter(selectedControl.Examples()); this.expList.SetAdapter(ea); for (int i = 0; i < ea.GroupCount; i++ ) { expList.ExpandGroup(i); } this.expList.ChildClick += (object sender, ExpandableListView.ChildClickEventArgs e) => { ExampleActivity.selectedExampleFragment = (Android.Support.V4.App.Fragment)ea.GetChild(e.GroupPosition, e.ChildPosition); Intent exampleIntent = new Intent(this, typeof(ExampleActivity)); this.StartActivity(exampleIntent); e.Handled = true; }; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = inflater.Inflate(Resource.Layout.MainTaskListFragment, container, false); View header = Activity.LayoutInflater.Inflate(Resource.Layout.MainTaskListHeader, null); mainList = view.FindViewById<ExpandableListView>(Resource.Id.mainActivitiesList); mainList.AddHeaderView(header, null, false); mainList.SetAdapter(new ScenarioListAdapter(Activity, AppData.Session.Categories.ToArray())); mainList.ChildClick += mainList_ChildClick; // When the pull to refresh is activated, pull new data from the server and refresh the list with the new data refresher = view.FindViewById<SwipeRefreshLayout>(Resource.Id.refresher); refresher.Refresh += async delegate { if (!AndroidUtils.IsConnected()) { AndroidUtils.OfflineAlert(Activity); refresher.Refreshing = false; return; } await ServerData.FetchCategories(); refresher.Refreshing = false; ((ScenarioListAdapter) mainList.ExpandableListAdapter).Categories = AppData.Session.Categories.ToArray(); Activity.RunOnUiThread( () => ((ScenarioListAdapter) mainList.ExpandableListAdapter).NotifyDataSetChanged()); }; // If there's only one category, it makes sense to expand it by default if (AppData.Session.Categories.Count == 1) { mainList.ExpandGroup(0, true); } practiceBtn = header.FindViewById<Button>(Resource.Id.practiceAreaBtn); practiceBtn.Click += practiceButton_Click; return view; }