private void SetupTable(List <TestResult> results) { var resultTableView = FindViewById <SortableTableView>(Resource.Id.tableView); var simpleTableHeaderAdapter = new SimpleTableHeaderAdapter(this, "Method", "Bytes", "KB", "Size Diff", "Time (ms)"); simpleTableHeaderAdapter.SetTextColor(ContextCompat.GetColor(this, Resource.Color.table_header_text)); resultTableView.HeaderAdapter = simpleTableHeaderAdapter; var rowColorEven = ContextCompat.GetColor(this, Resource.Color.table_data_row_even); var rowColorOdd = ContextCompat.GetColor(this, Resource.Color.table_data_row_odd); resultTableView.SetDataRowBackgroundProvider(TableDataRowBackgroundProviders.AlternatingRowColors(rowColorEven, rowColorOdd)); resultTableView.HeaderSortStateViewProvider = SortStateViewProviders.BrightArrows(); resultTableView.SetColumnWeight(0, 3); resultTableView.SetColumnWeight(1, 2); resultTableView.SetColumnWeight(2, 2); resultTableView.SetColumnWeight(3, 2); resultTableView.SetColumnWeight(4, 2); resultTableView.SetColumnComparator(1, ResultViewModel.GetBytesComparator()); resultTableView.SetColumnComparator(4, ResultViewModel.GetTimeComparator()); _tableAdapter = new ResultsTableAdapter(this, ResultViewModel.From(results)); resultTableView.DataAdapter = _tableAdapter; resultTableView.DataClick += (sender, e) => { var result = (ResultViewModel)e.ClickedData; var resultString = $"Tapped {result.Method}"; Toast.MakeText(this, resultString, ToastLength.Short).Show(); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); if (toolbar != null) { SetSupportActionBar(toolbar); } var carTableView = FindViewById <SortableTableView>(Resource.Id.tableView); var simpleTableHeaderAdapter = new SimpleTableHeaderAdapter(this, "Manufacturer", "Name", "Performance", "Price"); simpleTableHeaderAdapter.SetTextColor(ContextCompat.GetColor(this, Resource.Color.table_header_text)); carTableView.HeaderAdapter = simpleTableHeaderAdapter; var rowColorEven = ContextCompat.GetColor(this, Resource.Color.table_data_row_even); var rowColorOdd = ContextCompat.GetColor(this, Resource.Color.table_data_row_odd); carTableView.SetDataRowBackgroundProvider(TableDataRowBackgroundProviders.AlternatingRowColors(rowColorEven, rowColorOdd)); carTableView.HeaderSortStateViewProvider = SortStateViewProviders.BrightArrows(); carTableView.SetColumnWeight(0, 2); carTableView.SetColumnWeight(1, 3); carTableView.SetColumnWeight(2, 3); carTableView.SetColumnWeight(3, 2); carTableView.SetColumnComparator(0, database.GetCarProducerComparator()); carTableView.SetColumnComparator(1, database.GetCarNameComparator()); carTableView.SetColumnComparator(2, database.GetCarPowerComparator()); carTableView.SetColumnComparator(3, database.GetCarPriceComparator()); carTableView.DataAdapter = new CarTableDataAdapter(this, database.Cars); carTableView.DataClick += (sender, e) => { var car = (Car)e.ClickedData; var carString = car.Producer.Name + " " + car.Name; Toast.MakeText(this, carString, ToastLength.Short).Show(); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; tableview = FindViewById <SortableTableView>(Resource.Id.tableView); simpleTableHeaderAdapter = new SimpleTableHeaderAdapter(this, "Prueba 1", "Prueb 2", "Prueba 3", "Prueba 4"); simpleTableHeaderAdapter.SetTextColor(ContextCompat.GetColor(this, Resource.Color.table_header_text)); tableview.HeaderAdapter = simpleTableHeaderAdapter; rowColorEven = ContextCompat.GetColor(this, Resource.Color.table_data_row_even); rowColorOdd = ContextCompat.GetColor(this, Resource.Color.table_data_row_odd); tableview.SetDataRowBackgroundProvider(TableDataRowBackgroundProviders.AlternatingRowColors(rowColorEven, rowColorOdd)); tableview.HeaderSortStateViewProvider = SortStateViewProviders.BrightArrows(); tableview.SetColumnWeight(0, 2); tableview.SetColumnWeight(1, 3); tableview.SetColumnWeight(2, 3); tableview.SetColumnWeight(3, 2); tableview.SetColumnComparator(0, database.GetCarProducerComparator()); tableview.SetColumnComparator(1, database.GetCarNameComparator()); tableview.SetColumnComparator(2, database.GetCarPowerComparator()); tableview.SetColumnComparator(3, database.GetCarPriceComparator()); tableview.DataAdapter = new CarTableDataAdapter(this, database.Cars); tableview.DataClick += (sender, e) => { var car = (Car)e.ClickedData; var carString = car.Producer.Name + " " + car.Name; Toast.MakeText(this, carString, ToastLength.Short).Show(); }; }