protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); setupParent(FindViewById<LinearLayout>(Resource.Id.mainLayout)); listViewGoodsMain = FindViewById<ListView>(Resource.Id.listViewGoodsMain); goodsItemsList = new List<GoodsItem>(); goodsItemsList.Add(new GoodsItem() { Id = 1, Quantity = 1, Name = "Пельмешки"}); goodsItemsList.Add(new GoodsItem() { Id = 2, Quantity = 2, Name = "Сосисоны" }); myGoodsItemsAdapter = new GoodsItemsAdapter(this, goodsItemsList); listViewGoodsMain.Adapter = myGoodsItemsAdapter; var emptyText = FindViewById<TextView>(Resource.Id.textViewGoodsListEmpty); listViewGoodsMain.EmptyView = emptyText; editTextNewProduct = FindViewById<EditText>(Resource.Id.EditTextNewProduct); editTextNewProduct.EditorAction += editTextNewProduct_EditorAction; editTextNewProduct.Click += editTextNewProduct_Click; checkBoxRed = FindViewById<CheckBox>(Resource.Id.checkBoxRed); checkBoxRed.Click += checkBoxRed_Click; }
void editTextNewProduct_EditorAction(object sender, TextView.EditorActionEventArgs e) { e.Handled = false; if (e.ActionId == ImeAction.Done) { string goodsName = editTextNewProduct.Text; // get new item from input goodsItemsList.Add(new GoodsItem() {Name = goodsName, Quantity = 1}); myGoodsItemsAdapter = new GoodsItemsAdapter(this, goodsItemsList); // refresh list listViewGoodsMain.Adapter = myGoodsItemsAdapter; hideSoftKeyboard(); editTextNewProduct.Text = ""; // clear the editBox e.Handled = true; } }