protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Transactions); var accountPK = Intent.GetIntExtra("AccountPK", 0); transactons = new List <Transaction>(); MainActivity.db.readTransactionRecords(accountPK); // Get our button from the layout resource and attach an event to it Button addTransaction = FindViewById <Button>(Resource.Id.btnAddTransaction1); lstTransactions = FindViewById <ListView>(Resource.Id.lstTransactions); transactionAdapter = new TransactionListViewAdapter(this, transactons); lstTransactions.Adapter = transactionAdapter; //click events for short and long of the listview for the accounts lstTransactions.ItemClick += LstTransactions_ItemClick; lstTransactions.ItemLongClick += LstTransactions_ItemLongClick; addTransaction.Click += delegate { var intent = new Intent(this, typeof(EnterTransaction)); intent.PutExtra("AccountPK", accountPK); StartActivity(intent); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Transactions); accountPK = Intent.GetIntExtra("AccountPK", 0); accountName = Intent.GetStringExtra("AccountName"); // Get our button from the layout resource and attach an event to it mRecyclerView = FindViewById <RecyclerView>(Resource.Id.lstTransactions); transactions = new List <Transaction>(); MainActivity.db.readTransactionRecords(accountPK); mLayoutManager = new LinearLayoutManager(this); mRecyclerView.SetLayoutManager(mLayoutManager); mLayoutManager.ScrollToPosition(transactions.Count - 1); transactionAdapter = new TransactionListViewAdapter(transactions); transactionAdapter.ItemClick += OnItemClick; transactionAdapter.ItemLongClick += OnItemLongClick; mRecyclerView.SetAdapter(transactionAdapter); //top toolbar var toolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbar_top); SetActionBar(toolbar); ActionBar.Title = accountName; ActionBar.SetDisplayHomeAsUpEnabled(true); //enable the "up" button in the toolbar to navigate back //bottom toolbar var bottomToolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbar_bottom); bottomToolbar.Title = ""; bottomToolbar.InflateMenu(Resource.Menu.bottom_menu_transaction_list); bottomToolbar.MenuItemClick += (sender, e) => { if (e.Item.TitleFormatted.ToString() == "Add") { var intent = new Intent(this, typeof(Add_Edit_Transaction)); intent.PutExtra("Type", "Add"); //inform this is a new transaction intent.PutExtra("AccountPK", accountPK); intent.PutExtra("AccountName", accountName); StartActivity(intent); } }; }