protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // setup ui SetContentView(Resource.Layout.activity_list); // get list view var view = FindViewById <ListView>(Resource.Id.listView); // get data from intent float speed = Intent.GetFloatExtra(SPEED_KEY, 0); float distance = Intent.GetFloatExtra(DISTANCE_KEY, 0); float angle = Intent.GetFloatExtra(ANGLE_KEY, 0); // create list of data List <string> data = new List <string>(); // get length that is a percentage of distance float increment = distance * DISTANCE_PERCENT; float x = 0; while (x <= distance) { // get elevation float y = BallisticTools.GetElevationAtDistance(speed, x, angle); // create string var entry = string.Format("( {0}, {1} )", x.ToString("n0"), y.ToString("n2")); // add to list data.Add(entry); // end if (x >= distance) { break; } // next distance mark x += increment; // cap distance if (x > distance) { x = distance; } } // plug in data to list view view.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, data); }
void NewData(object sender, TextChangedEventArgs e) { // get input bool tp1 = float.TryParse(speedField.Text, out speed); bool tp2 = float.TryParse(xField.Text, out x); bool tp3 = float.TryParse(yField.Text, out y); bool tp4 = float.TryParse(zeroField.Text, out zero); // put in array bool[] dataEntry = { tp1, tp2, tp3, tp4 }; // calculate progress progressBar.SetProgress(0, false); foreach (bool b in dataEntry) { if (b) { // update progress bar progressBar.IncrementProgressBy(25); } } // try to calculate if (progressBar.Progress == 100) { // get launch angle angle = BallisticTools.GetLaunchAngle(speed, x, y); // get hold double hold = BallisticTools.GetHold(angle, speed, x, y, zero); // display hold holdLabel.Text = string.Format("Hold {0} (m) Over", hold.ToString("n2")); // get flight time float flightTime = BallisticTools.GetFlightTime(angle, speed, x); // display flight time timeLabel.Text = string.Format("{0} (s) Flight Time", flightTime.ToString("n2")); } }