protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our controls from the layout resource mRecyclerView = FindViewById <RecyclerView>(Resource.Id.lstAccounts); //initialize the database class db = new Database(); //create a new account list accounts = new List <Account>(); //load accounts from the database (adds the accounts in the account list) db.readAccounts(); //setup the layout manager and set the recyclerview to use it mLayoutManager = new LinearLayoutManager(this); mRecyclerView.SetLayoutManager(mLayoutManager); //create a new account list view adapter and set the listview from the layouts adapter to the custom one accountAdapter = new AccountListViewAdapter(accounts); accountAdapter.ItemClick += OnItemClick; accountAdapter.ItemLongClick += OnItemLongClick; mRecyclerView.SetAdapter(accountAdapter); //top toolbar var toolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbar_top); SetActionBar(toolbar); ActionBar.Title = "Account Overview"; //bottom toolbar var bottomToolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbar_bottom); bottomToolbar.Title = ""; bottomToolbar.InflateMenu(Resource.Menu.bottom_menu_account_list); bottomToolbar.MenuItemClick += (sender, e) => { //when the add button is clicked on the bottom toolbar if (e.Item.TitleFormatted.ToString() == "Add") { var intent = new Intent(this, typeof(Add_Edit_Account)); intent.PutExtra("Type", "Add"); //inform this is a new account StartActivity(intent); } //when the bill reminder button is clicked on the bottom toolbar else if (e.Item.TitleFormatted.ToString() == "Bill Reminder") { Toast.MakeText(this, "Bill Reminder: Furture Enhancement", ToastLength.Short).Show(); } }; }
protected override void OnCreate(Bundle savedInstanceState) { //hide the title bar RequestWindowFeature(Android.Views.WindowFeatures.NoTitle); base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource and attach an event to it lstAccounts = FindViewById <ListView>(Resource.Id.lstAccounts); Button btnBillReminder = FindViewById <Button>(Resource.Id.btnBillReminder); Button btnAddAccount = FindViewById <Button>(Resource.Id.btnAddAccount); db = new Database(); accounts = new List <Account>(); //load accounts from the database db.readAccounts(); accountAdapter = new AccountListViewAdapter(this, accounts); lstAccounts.Adapter = accountAdapter; //click events for short and long of the listview for the accounts lstAccounts.ItemClick += LstAccounts_ItemClick; lstAccounts.ItemLongClick += LstAccounts_ItemLongClick; btnBillReminder.Click += delegate { Toast.MakeText(this, "Bill Reminder in future", ToastLength.Short).Show(); }; btnAddAccount.Click += delegate { var intent = new Intent(this, typeof(AddAccount)); StartActivity(intent); }; }