Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.user_list_layout);
            listView1 = FindViewById <ListView>(Resource.Id.listViewUser);
            mySearch  = FindViewById <SearchView>(Resource.Id.searchView1);

            DBHelper myDBHelper = new DBHelper(this);

            ICursor result = myDBHelper.getUserList();

            while (result.MoveToNext())
            {
                //userN = result.GetString(result.GetColumnIndexOrThrow("f_name"));
                //System.Console.WriteLine(" The name of user is " + userN);

                //arr_list.Add(result.GetString(result.GetColumnIndex("f_name")));

                myUserList.Add(new UserObject(result.GetString(result.GetColumnIndex("f_name")), result.GetString(result.GetColumnIndex("age")), Resource.Drawable.dd));
            }
            CustomAdaptor adapter = new CustomAdaptor(this, myUserList); // Context

            listView1.Adapter         = adapter;
            listView1.ItemClick      += ListView1_ItemClick;
            mySearch.QueryTextChange += MySearch_QueryTextChange;
        }
Ejemplo n.º 2
0
 private void MySearch_QueryTextChange(object sender, SearchView.QueryTextChangeEventArgs e)
 {
     //var mySearchValue = e.NewText;
     if (string.IsNullOrWhiteSpace(e.NewText))
     {
         CustomAdaptor myAdapter = new CustomAdaptor(this, myUserList);
         listView1.Adapter = myAdapter;
     }
     else
     {
         CustomAdaptor myAdapter = new CustomAdaptor(this, myUserList.Where(us => us.name.StartsWith(e.NewText)).ToList());
         listView1.Adapter = myAdapter;
     }
 }