예제 #1
0
        private void mSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            List <Person> searchPerson = (from person in mItems
                                          where person.FirstName.ToLower().Contains(mSearch.Text.ToLower()) || person.Age.Contains(mSearch.Text)
                                          select person).ToList <Person>();

            adapter           = new ListViewAdapter(this, searchPerson, Resource.Layout.listview_row);
            mListView.Adapter = adapter;
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            mListView  = FindViewById <ListView>(Resource.Id.friendsView);
            mSearch    = FindViewById <EditText>(Resource.Id.mSearch);
            mContainer = FindViewById <LinearLayout>(Resource.Id.Container);

            mHeaderFirstName = FindViewById <TextView>(Resource.Id.txtHeaderFirstName);
            mHeaderLastName  = FindViewById <TextView>(Resource.Id.txtHeaderLastName);
            mHeaderAge       = FindViewById <TextView>(Resource.Id.txtHeaderAge);
            mHeaderGender    = FindViewById <TextView>(Resource.Id.txtHeaderGender);

            mHeaderFirstName.Click += mHeaderFirstName_Click;
            mHeaderLastName.Click  += mHeaderLastName_Click;
            mHeaderAge.Click       += mHeaderAge_Click;
            mHeaderGender.Click    += mHeaderGender_Click;

            mSearch.Alpha        = 0;
            mSearch.TextChanged += mSearch_TextChanged;
            mContainer.BringToFront();

            mItems = new List <Person>();
            mItems.Add(new Person()
            {
                FirstName = "Marian", LastName = "Kowal", Age = "20", Gender = "M"
            });
            mItems.Add(new Person()
            {
                FirstName = "Janusz", LastName = "Liśc", Age = "29", Gender = "M"
            });
            mItems.Add(new Person()
            {
                FirstName = "Grażyna", LastName = "Bąk", Age = "32", Gender = "K"
            });

            adapter = new ListViewAdapter(this, mItems, Resource.Layout.listview_row);

            mListView.Adapter = adapter;


            mListView.ItemClick += mListView_ItemClick;
        }
예제 #3
0
        private void mHeaderGender_Click(object sender, EventArgs e)
        {
            List <Person> filteredPersons;

            if (!mGenderFilterAsc)
            {
                filteredPersons = (from person in mItems
                                   orderby person.Gender ascending
                                   select person).ToList <Person>();
            }
            else
            {
                filteredPersons = (from person in mItems
                                   orderby person.Gender descending
                                   select person).ToList <Person>();
            }
            adapter           = new ListViewAdapter(this, filteredPersons, Resource.Layout.listview_row);
            mListView.Adapter = adapter;
            mGenderFilterAsc  = !mGenderFilterAsc;
        }