Example #1
0
        //Sort list name wise and update list view
        void UpdatePlayerList()
        {
            pList = dbManager.ViewAllSortByName();
            PlayerAdapter myDataAdapter = new PlayerAdapter(this, pList);

            playerList.Adapter = myDataAdapter;
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            btnplay               = FindViewById <Button>(Resource.Id.btnPlay);
            btnplay.Click        += Play_Game;
            btnadd                = FindViewById <Button>(Resource.Id.btnAdd);
            btnadd.Click         += Btnadd_Click;
            tName                 = FindViewById <TextView>(Resource.Id.txtName);
            chkEasy               = FindViewById <CheckBox>(Resource.Id.cbxEasy);
            chkNormal             = FindViewById <CheckBox>(Resource.Id.cbxNormal);
            chkDifficult          = FindViewById <CheckBox>(Resource.Id.cbxDifficult);
            playerList            = FindViewById <ListView>(Resource.Id.listView1);
            playerList.ItemClick += PlayerList_ItemClick1;
            dbManager             = new DatabaseManager();
            UpdatePlayerList();
            updateData = pList;
            PlayerAdapter myAdapter = new PlayerAdapter(this, pList);

            playerList.Adapter = myAdapter;
// Check if entered name already exist in database
            tName.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                // filter Playerlist on text changed
                var searchTerm = tName.Text;
                updateData = pList.Where(player => player.PlayerName.ToLower().Contains(searchTerm.ToLower())
                                         ).ToList();
                var filteredResultsAdapter = new PlayerAdapter(this, updateData);
                playerList.Adapter = filteredResultsAdapter;
            };
        }