public override void ViewDidLoad() { base.ViewDidLoad(); AutoCompleteMode.Text = NSBundle.MainBundle.GetLocalizedString("AutoCompleteMode", ""); ShowClearButton.Text = NSBundle.MainBundle.GetLocalizedString("ShowClearButton", ""); clearSwitch.ValueChanged += ClearSwitch_ValueChanged; clearSwitch.On = false; HighlightDropdown.DropDownHeight = 200; HighlightDropdown.DisplayMemberPath = "Name"; HighlightDropdown.IsAnimated = true; HighlightDropdown.ItemsSource = Countries.GetDemoDataList(); CustomDropdown.DropDownHeight = 200; CustomDropdown.DisplayMemberPath = @"Name"; CustomDropdown.IsAnimated = true; CustomDropdown.HighlightedColor = UIColor.Red; CustomDropdown.ItemsSource = Countries.GetDemoImageDataList(); CustomDropdown.ItemLoading += (s, e) => { e.ItemView = GetCountryCell(CustomDropdown, e.Item as Countries, e); }; FilterDropdown.DisplayMemberPath = "Title"; FilterDropdown.DropDownHeight = 200; FilterDropdown.Filtering += async(sender, e) => { var deferral = e.GetDeferral(); try { var collectionView = new YouTubeCollectionView(); await collectionView.SearchAsync(e.FilterString); FilterDropdown.ItemsSource = collectionView; e.Cancel = true; } finally { deferral.Complete(); } }; FilterDropdown.ItemLoading += (s, e) => { e.ItemView = GetYoutubeCell(FilterDropdown, e.Item as YouTubeVideo, e); }; FilterDropdown.IsAnimated = true; acmField.ToPickerWithValues(ACMItems, 0, (selectedIndex) => { HighlightDropdown.AutoCompleteMode = (C1.iOS.Input.AutoCompleteMode)Enum.Parse(typeof(C1.iOS.Input.AutoCompleteMode), ACMItems[selectedIndex]); CustomDropdown.AutoCompleteMode = (C1.iOS.Input.AutoCompleteMode)Enum.Parse(typeof(C1.iOS.Input.AutoCompleteMode), ACMItems[selectedIndex]); FilterDropdown.AutoCompleteMode = (C1.iOS.Input.AutoCompleteMode)Enum.Parse(typeof(C1.iOS.Input.AutoCompleteMode), ACMItems[selectedIndex]); }); }
private async void OnDynamicFiltering(object sender, AutoCompleteFilteringEventArgs e) { var autoComplete = sender as C1AutoComplete; var deferal = e.GetDeferral(); try { var collectionView = new YouTubeCollectionView(); await collectionView.SearchAsync(e.FilterString); autoComplete.ItemsSource = collectionView; e.Cancel = true; } finally { deferal.Complete(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_autocomplete); acmSpinner = (Spinner)FindViewById(Resource.Id.acm_Spinner); clearSwitch = (Switch)FindViewById(Resource.Id.clear_switch); acmTextView = (TextView)FindViewById(Resource.Id.acm_textview); clearTextView = (TextView)FindViewById(Resource.Id.clear_textview); acmTextView.Text = GetString(Resource.String.AutoCompleteMode); clearTextView.Text = GetString(Resource.String.ShowClearButton); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = GetString(Resource.String.autocomplete); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); highLightAutoComplete = (C1AutoComplete)this.FindViewById(Resource.Id.autocomplete_highlight); highLightAutoComplete.ItemsSource = Country.GetDemoDataList(); highLightAutoComplete.DisplayMemberPath = "Name"; customAutoComplete = (C1AutoComplete)this.FindViewById(Resource.Id.autocomplete_custom); customAutoComplete.ItemsSource = CountryWithFlag.GetDemoDataList(); customAutoComplete.DisplayMemberPath = "Name"; customAutoComplete.ItemLoading += (object sender, ComboBoxItemLoadingEventArgs e) => { CreateItemView(e.Item as CountryWithFlag, e); }; filterAutoComplete = (C1AutoComplete)this.FindViewById(Resource.Id.autocomplete_filter); filterAutoComplete.DisplayMemberPath = "Title"; filterAutoComplete.Filtering += async(sender, e) => { var deferral = e.GetDeferral(); try { var collectionView = new YouTubeCollectionView(); await collectionView.SearchAsync(e.FilterString); filterAutoComplete.ItemsSource = collectionView; e.Cancel = true; } finally { deferral.Complete(); } }; filterAutoComplete.ItemLoading += (object sender, ComboBoxItemLoadingEventArgs e) => { CreateYouTubeItemView(e.Item as YouTubeVideo, e); }; ArrayAdapter adapter1 = ArrayAdapter.CreateFromResource(this, Resource.Array.acmSpinnerValues, Android.Resource.Layout.SimpleSpinnerItem); // Specify the layout to use when the list of choices appears adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); // Apply the adapter to the spinner acmSpinner.Adapter = adapter1; acmSpinner.SetSelection(1); acmSpinner.ItemSelected += AcmSpinner_ItemSelected; clearSwitch.Checked = false; clearSwitch.CheckedChange += ClearSwitch_CheckedChange; }