Пример #1
0
        public void mySearchMethod(object sender, SearchView.QueryTextChangeEventArgs e)
        {
            RadioGroup  searchColumn = FindViewById <RadioGroup>(Resource.Id.searchTypeRG);
            RadioButton nameSearch   = FindViewById <RadioButton>(Resource.Id.NameSearchID);

            nameSearch.Checked = true;
            var      columnName    = (FindViewById <RadioButton>(searchColumn.CheckedRadioButtonId)).Text;
            DBHelper sqlFunctions  = new DBHelper(this);
            var      mySearchValue = e.NewText;

            //call search func
            System.Console.WriteLine("Search Text is :  is \n\n " + mySearchValue);
            ICursor newDetails = sqlFunctions.searchResult(columnName, mySearchValue);

            if (newDetails.Count != 0)
            {
                myUserList.Clear();
            }
            while (newDetails.MoveToNext())
            {
                myUserList.Add(new UserObject(newDetails.GetString(newDetails.GetColumnIndexOrThrow("Name")), newDetails.GetString(newDetails.GetColumnIndexOrThrow("Email")), 3));
            }

            myList = FindViewById <ListView>(Resource.Id.listViewID);

            var myAdapter = new MyCustomAdapter(this, myUserList);

            myList.SetAdapter(myAdapter);
            myList.ItemClick += myItemClickMethod;

            mySearch = FindViewById <SearchView>(Resource.Id.searchID);
            //Search Events
            mySearch.QueryTextChange += mySearchMethod;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.favTeacher);
            //spinner

            /*   Spinner spinner = FindViewById<Spinner>(Resource.Id.spinner2);
             *
             * spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
             * var adapter = ArrayAdapter.CreateFromResource(
             *         this, Resource.Array.planets_array, Android.Resource.Layout.SimpleSpinnerItem);
             *
             * adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
             * spinner.Adapter = adapter;
             */
            DBHelper sqlFunctions = new DBHelper(this);
            ICursor  details      = sqlFunctions.searchFavResult();

            myFavList.Add(new UserObject("Gurjot", "*****@*****.**", 4));

            while (details.MoveToNext())
            {
                myFavList.Add(new UserObject(details.GetString(details.GetColumnIndexOrThrow("Name")), details.GetString(details.GetColumnIndexOrThrow("Email")), 3));
            }
            myList = FindViewById <ListView>(Resource.Id.favlistViewID);

            var myAdapter = new MyCustomAdapter(this, myFavList);

            myList.SetAdapter(myAdapter);
            //    myList.ItemClick += myItemClickMethod;
        }
Пример #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Search);

            //spinner

            /* Spinner spinner = FindViewById<Spinner>(Resource.Id.spinner1);
             *
             * spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
             * var adapter = ArrayAdapter.CreateFromResource(
             *       this, Resource.Array.planets_array, Android.Resource.Layout.SimpleSpinnerItem);
             *
             * adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
             * spinner.Adapter = adapter;
             */

            /*        Button favourite = FindViewById<Button>(Resource.Id.advancedSearch);
             *      favourite.Click += delegate
             *      {
             *          Intent fav = new Intent(this, typeof(favouriteTeacher));
             *          StartActivity(fav);
             *      };
             */
            DBHelper sqlFunctions = new DBHelper(this);
            ICursor  details      = sqlFunctions.searchResult("Name", "");

            // Set our view from the "main" layout resource
            while (details.MoveToNext())
            {
                myUserList.Add(new UserObject(details.GetString(details.GetColumnIndexOrThrow("Name")), details.GetString(details.GetColumnIndexOrThrow("Email")), 3));
            }
            myList = FindViewById <ListView>(Resource.Id.listViewID);

            var myAdapter = new MyCustomAdapter(this, myUserList);

            myList.SetAdapter(myAdapter);
            myList.ItemClick += myItemClickMethod;


            Button favButton = FindViewById <Button>(Resource.Id.addToFav);

            mySearch = FindViewById <SearchView>(Resource.Id.searchID);
            //Search Events
            mySearch.QueryTextChange += mySearchMethod;
            favButton.Click          += delegate
            {
                Intent favT = new Intent(this, typeof(favouriteTeacher));
                StartActivity(favT);
            };
        }