Esempio n. 1
0
        public void filter(FriendsCustomAdapter adapter, string constraint)
        {
            if (constraint != null && constraint.Length > 0)
            {
                ObservableCollection <UserItem> matchList = new ObservableCollection <UserItem>();
                foreach (UserItem item in adapter.persons.ToList())

                {
                    if (item.Name.StartsWith(constraint.ToString()))
                    {
                        matchList.Add(item);
                    }
                }

                adapter.persons = matchList;
                adapter.NotifyDataSetChanged();
            }
        }
Esempio n. 2
0
            protected override void PublishResults(ICharSequence constraint, FilterResults results)
            {
                ObservableCollection <UserItem> items = new ObservableCollection <UserItem>();

                if (constraint != null && constraint.Length() > 0)
                {
                    Java.Lang.Object[] values = (Java.Lang.Object[])results.Values;
                    for (int i = 0; i < values.Length; i++)
                    {
                        items.Add(new UserItem
                        {
                            Name = values.GetValue(i).ToString()
                        }
                                  );
                    }
                }

                friendsCustomAdapter.persons = items;
                friendsCustomAdapter.NotifyDataSetChanged();
            }