コード例 #1
0
        private void AddPlace(Place newPlace, bool showToast = true)
        {
            if (chosenPlaces.Exists((p) => p.GooglePlaceId == newPlace.GooglePlaceId))
            {
                if (showToast)
                {
                    Toast.MakeText(this, $"Already added '{newPlace.Name}'", ToastLength.Long).Show();
                }
                return;
            }

            View child = LayoutInflater.Inflate(Resource.Layout.CreateTaskMultipleChoiceEntry, null);

            child.FindViewById <TextView>(Resource.Id.option).Text            = newPlace.Name;
            child.FindViewById <ImageButton>(Resource.Id.deleteButton).Click += DeletePlace;
            child.Id = rand.Next();

            chosenPlaces.Add(newPlace);

            using (LinearLayout choicesRoot = FindViewById <LinearLayout>(Resource.Id.placesRoot))
            {
                choicesRoot.AddView(child);
                choicesRoot.Visibility = ViewStates.Visible;
            }
        }
コード例 #2
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            if (requestCode != placePickerReq || resultCode != Result.Ok)
            {
                return;
            }

            IPlace place = PlaceAutocomplete.GetPlace(this, data);

            Place newPlace = new Place
            {
                GooglePlaceId = place.Id,
                Latitude      = new decimal(place.LatLng.Latitude),
                Longitude     = new decimal(place.LatLng.Longitude),
                Name          = place.NameFormatted.ToString()
            };

            AddPlace(newPlace);
        }