// List View code public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View firstView = inflater.Inflate(Resource.Layout.firstfragment, container, false); myOptions = firstView.FindViewById <Spinner>(Resource.Id.mySpinnerId); listView = firstView.FindViewById <ListView>(Resource.Id.myListID); searchView = firstView.FindViewById <SearchView>(Resource.Id.searchViewId); myObj = new UserObject(); myObject = new UserObject1(); myUserList = myObj.createListOfUsers(); var myCustomerAdapter = new myCustomAdapter(context, myUserList); listView.SetAdapter(myCustomerAdapter); myEventsList = myObject.eventList(); var adatperSpinner = new myCustomAdapter1(context, myEventsList); myOptions.Adapter = adatperSpinner; myOptions.ItemSelected += MyOptions_ItemSelected; listView.ItemClick += myListViewEvent; searchView.QueryTextChange += searchView_QueryTextChange; return(firstView); //return base.OnCreateView(inflater, container, savedInstanceState); }
//search view code private void searchView_QueryTextChange(object sender, SearchView.QueryTextChangeEventArgs e) { var value = e.NewText; System.Console.WriteLine("value" + value); List <UserObject> filterList = new List <UserObject>(); foreach (UserObject aobj in myUserList) { if (aobj.name.ToLower().Contains(value.ToLower())) { filterList.Add(aobj); } } var newFilter = new myCustomAdapter(context , filterList); listView.SetAdapter(newFilter); //list view declared in this }
void MyOptions_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { // var index = e.Position; // var value = items[index]; //System.Console.WriteLine("value is " + value); switch (e.Position) { case 0: myUserList = myObj.createListOfUsers(); var myCustomerAdapter = new myCustomAdapter(context, myUserList); listView.SetAdapter(myCustomerAdapter); break; case 1: myUserList = myObj.createListOfUsers1(); var myCustomerAdapter1 = new myCustomAdapter(context, myUserList); listView.SetAdapter(myCustomerAdapter1); break; case 2: myUserList = myObj.createListOfUsers2(); var myCustomerAdapter2 = new myCustomAdapter(context, myUserList); listView.SetAdapter(myCustomerAdapter2); break; case 3: myUserList = myObj.createListOfUsers3(); var myCustomerAdapter3 = new myCustomAdapter(context, myUserList); listView.SetAdapter(myCustomerAdapter3); break; default: System.Console.WriteLine(" "); break; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View firstView = inflater.Inflate(Resource.Layout.thirdFragment, container, false); listView = firstView.FindViewById <ListView>(Resource.Id.favListID); // searchView = firstView.FindViewById<SearchView>(Resource.Id.searchViewId); myObj = new UserObject(); myObject = new UserObject1(); favList = dBHelper.selectAllFavrouites(); var favCustomerAdapter = new myCustomAdapter(context, favList); listView.SetAdapter(favCustomerAdapter); listView.ItemClick += myListViewEvent; // searchView.QueryTextChange += searchView_QueryTextChange; return(firstView); //return base.OnCreateView(inflater, container, savedInstanceState); }