private void OnSerachChange(object sender, SearchView.QueryTextChangeEventArgs e) { var dataset = locationDb.GetLocationsAsync().Result; if (string.IsNullOrWhiteSpace(e.NewText)) { LocationAdapter myAdapter = new LocationAdapter(this, dataset); listView.Adapter = myAdapter; } else { LocationAdapter myAdapter = new LocationAdapter(this, dataset.Where(us => us.Name.ToLower().StartsWith(e.NewText.ToLower())).ToList()); listView.Adapter = myAdapter; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // check if user is login if (App.username == null) { Intent ints = new Intent(this, typeof(LoginActivity)); StartActivity(ints); } SetContentView(Resource.Layout.locationPage); // on logout button click FindViewById <Button>(Resource.Id.btnLocationLogout) .Click += (s, arg) => { App.username = null; Intent ints = new Intent(this, typeof(LoginActivity)); StartActivity(ints); }; // on checkout button click FindViewById <Button>(Resource.Id.btnLoactionCheckout) .Click += (s, arg) => { Intent ints = new Intent(this, typeof(CheckoutActivity)); StartActivity(ints); }; // Create your application here locationDb = new LocationDataBase(SharedHelper.DbPath); //var checkout = FindViewById<>(Resource.Id.checkout); listView = FindViewById <ListView>(Resource.Id.listView1); searchView1 = FindViewById <SearchView>(Resource.Id.searchView1); LocationAdapter lp = new LocationAdapter(this, locationDb.GetLocationsAsync().Result); listView.Adapter = lp; listView.ItemClick += OnListClicked; searchView1.QueryTextChange += OnSerachChange; }