Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "LocalLend";
            toolbar.SetTitleTextAppearance(this, Resource.Style.TitleTextApperance);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            toolbar.SetLogo(Resource.Drawable.logo);

            btnLend   = FindViewById <Button>(Resource.Id.btnLend);
            lvItems   = FindViewById <ListView>(Resource.Id.lvItems);
            txtSearch = FindViewById <EditText>(Resource.Id.txtSearch);

            LoadItemsFromDataStore();

            adapter         = new BorrowListAdapter(this, itemList);
            lvItems.Adapter = adapter;

            txtSearch.TextChanged += TxtSearch_TextChanged;
            lvItems.ItemClick     += LvItems_ItemClick;
            btnLend.Click         += BtnLend_Click;
        }
Пример #2
0
        //Search filters based on typing item name
        private void TxtSearch_TextChanged(object sender, Android.Text.TextChangedEventArgs e)
        {
            var         itemToLower   = txtSearch.Text.ToLower();
            List <Item> searchedItems = (from item in itemList
                                         where item.ItemName.ToLower().StartsWith(itemToLower) || item.ItemName.ToLower().Contains(itemToLower)
                                         select item).ToList <Item>();

            adapter         = new BorrowListAdapter(this, searchedItems);
            lvItems.Adapter = adapter;
        }
Пример #3
0
        //Adds item and refreshes BorrowList in MainActivity
        private void LendDialog_OnCreateItem(object sender, AddItemToListEventArgs e)
        {
            item = new Item()
            {
                ItemName        = e.ItemName,
                ItemDescription = e.ItemDescription,
                ItemImage       = e.Image.ToString(),
                Availability    = e.Availability
            };

            database.InsertIntoTableItem(item);

            LoadItemsFromDataStore();

            adapter         = new BorrowListAdapter(this, itemList);
            lvItems.Adapter = adapter;
            adapter.NotifyDataSetChanged();
        }