private void OnListClicked(object sender, AdapterView.ItemClickEventArgs e) { //var activity2 = new Intent(this, typeof(Activity2)); //activity2.PutExtra("MyData", "Data from Activity1"); //StartActivity(activity2); if (e != null) { App.selectedLocation.Postion = e.Position; App.selectedLocation.LocationID = Convert.ToInt32(e.Id); var loc = locationDb.GetLocationAsync(App.selectedLocation.LocationID).Result; App.selectedLocation.Name = loc.Name; App.selectedLocation.Price = loc.Price; } Intent ints = new Intent(this, typeof(ChartActivity)); StartActivity(ints); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.checkout); // initialize databases trDb = new TravelingLocationDataBase(SharedHelper.DbPath); locDb = new LocationDataBase(SharedHelper.DbPath); // get resource variables listViewCheckout = FindViewById <ListView>(Resource.Id.listViewCheckout); txtTotalPrice = FindViewById <TextView>(Resource.Id.txtTotalPrice); // add value to list adapter var travelLocation = trDb.GetTravelLocationByUserIdAsync(App.username).Result; if (travelLocation.Count <= 0) { new MessageHelper().alertFunction("Error", "Please select the locations", this); Intent ints = new Intent(this, typeof(LocationActivity)); StartActivity(ints); } List <Location> selectedLoc = new List <Location>(); for (int trvLoc = 0; trvLoc < travelLocation.Count; trvLoc++) { selectedLoc.Add(locDb.GetLocationAsync(travelLocation[trvLoc].LocationId).Result); } LocationAdapter lp = new LocationAdapter(this, selectedLoc); listViewCheckout.Adapter = lp; listViewCheckout.ItemClick += OnListClicked; // calculate total price txtTotalPrice.Text = selectedLoc.Select(sa => sa.Price).Sum().ToString(); }