Exemplo n.º 1
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Gigs = new List <Gig>();

            ListView        listView   = FindViewById <ListView>(Resource.Id.GigList);
            EditText        filterList = FindViewById <EditText>(Resource.Id.filterList);
            GigsListAdapter adapter;

            try
            {
                JsonValue json = await FetchGigsAsync(GetString(Resource.String.gigs_url));

                Console.WriteLine("jsonCount: " + json.Count);
                ParseAndDisplay(json, ref Gigs);


                adapter          = new GigsListAdapter(this, Gigs);
                listView.Adapter = adapter;
            }
            catch (WebException ex)
            {
                Console.WriteLine("An Error in the internet connection has occured" + ex.Message);
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error has occured -->" + ex.Message);
                throw;
            }

            filterList.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) =>
            {
                string searchText = e.Text.ToString();

                if (searchText != "")
                {
                    var newList =
                        from items in Gigs
                        where items.Description.ToLower().Contains(searchText)
                        select items;
                    listView.Adapter = new GigsListAdapter(this, newList.ToList());
                }
                else
                {
                    listView.Adapter = adapter;
                }
            };
        }
Exemplo n.º 2
0
 public GigsFilter(GigsListAdapter adapter)
 {
     _adapter = adapter;
 }