public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView ?? activity.LayoutInflater.Inflate(Resource.Layout.entry_list_item, parent, false); TextView entryDate = view.FindViewById <TextView>(Resource.Id.entry_date_text); TextView entryDescription = view.FindViewById <TextView>(Resource.Id.entry_desc_text); TextView entryAmount = view.FindViewById <TextView>(Resource.Id.entry_amount_text); entryDate.Text = entryList[position].Date; entryDescription.Text = entryList[position].Description; entryAmount.Text = entryList[position].TotalAmount + " " + activity.GetString(Resource.String.currency); bookKeeperManager = BookKeeperManager.Instance; Account account = bookKeeperManager.GetAccount(entryList[position].AccountNumber); // Set different colors according to type of transaction Expense/Income if (account.Type == Account.AccountType.Income) { entryDate.SetTextColor(Android.Graphics.Color.PaleTurquoise); entryDescription.SetTextColor(Android.Graphics.Color.PaleTurquoise); entryAmount.SetTextColor(Android.Graphics.Color.PaleTurquoise); } else if (account.Type == Account.AccountType.Expense) { entryDate.SetTextColor(Android.Graphics.Color.Orange); entryDescription.SetTextColor(Android.Graphics.Color.Orange); entryAmount.SetTextColor(Android.Graphics.Color.Orange); } return(view); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "activity_create_new_entry" layout resource SetContentView(Resource.Layout.activity_create_new_entry); // Get an instance of BookKeeperManager bookKeeperManager = BookKeeperManager.Instance; dateOfEntry = FindViewById <EditText>(Resource.Id.date_edit); datePickerButton = FindViewById <Button>(Resource.Id.date_picker_button); entryDescription = FindViewById <EditText>(Resource.Id.entry_description_edit); typeSpinner = FindViewById <Spinner>(Resource.Id.type_spinner); income_radio = FindViewById <RadioButton>(Resource.Id.income_radio_button); cost_radio = FindViewById <RadioButton>(Resource.Id.cost_radio_button); accountSpinner = FindViewById <Spinner>(Resource.Id.account_spinner); taxSpinner = FindViewById <Spinner>(Resource.Id.tax_spinner); totalWithoutTax = FindViewById <TextView>(Resource.Id.calculated_total_without_tax_text); totalWithTax = FindViewById <EditText>(Resource.Id.total_with_tax_edit); takePhotoButton = FindViewById <Button>(Resource.Id.take_photo_button); receiptImage = FindViewById <ImageView>(Resource.Id.receipt_image); saveButton = FindViewById <Button>(Resource.Id.save_entry_button); deleteButton = FindViewById <Button>(Resource.Id.delete_entry_button); activityType = Intent.GetStringExtra("activityType"); if ("new".Equals(activityType)) { income_radio.Checked = true; date = DateTime.Today; UpdateDate(); deleteButton.Enabled = false; populateTypeSpinner(); PopulateAccountSpinner(); PopulateTaxSpinner(); HandleEvents(); } else if ("update".Equals(activityType)) { entryId = Intent.GetIntExtra("entryId", -1); if (entryId != -1) { SetUpEntryDataForUpdate(); HandleEvents(); } else { Toast.MakeText(this, GetString(Resource.String.entry_not_found), ToastLength.Short).Show(); } } else { // Do nothing --- show toast ?? } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "activity_show_all_entries" layout resource SetContentView(Resource.Layout.activity_show_all_entries); bookKeeperManager = BookKeeperManager.Instance; entriesListView = FindViewById <ListView>(Resource.Id.entries_list_view); entriesListView.ItemClick += entriesListView_ItemClick; }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.new_entry); BKM = BookKeeperManager.Instance; RadioButton incomeRb = FindViewById<RadioButton> (Resource.Id.income); RadioButton expenseRb = FindViewById<RadioButton> (Resource.Id.expense); typeSp = FindViewById<Spinner> (Resource.Id.type_spinner); incomeRb.Click += delegate { inOut="income"; ArrayAdapter typeAdapter = new ArrayAdapter (this,Android.Resource.Layout.SimpleSpinnerDropDownItem,BKM.IncomeAccounts); typeSp.Adapter = typeAdapter; }; expenseRb.Click += delegate { inOut="expense"; ArrayAdapter typeAdapter = new ArrayAdapter (this,Android.Resource.Layout.SimpleSpinnerDropDownItem,BKM.ExpenseAccounts); typeSp.Adapter = typeAdapter; }; typeSp.ItemSelected += delegate { type = typeSp.SelectedItem.ToString(); }; Spinner moneyAccountSp = FindViewById<Spinner> (Resource.Id.to_from_spinner); ArrayAdapter maAdapter = new ArrayAdapter (this,Android.Resource.Layout.SimpleSpinnerDropDownItem,BKM.MoneyAccounts); moneyAccountSp.Adapter = maAdapter; moneyAccountSp.ItemSelected += delegate { moneyAccount = moneyAccountSp.SelectedItem.ToString(); }; Spinner taxSp = FindViewById<Spinner> (Resource.Id.tax_spinner); ArrayAdapter taxAdapter = new ArrayAdapter (this,Android.Resource.Layout.SimpleSpinnerDropDownItem,BKM.TaxRates); taxSp.Adapter = taxAdapter; taxSp.ItemSelected += delegate { taxRate = taxSp.SelectedItem.ToString(); }; Button addButton = FindViewById<Button> (Resource.Id.add_button); addButton.Click += delegate { string date = FindViewById<EditText>(Resource.Id.date_input).Text; string description = FindViewById<EditText>(Resource.Id.description_input).Text; string totalAmount = FindViewById<EditText>(Resource.Id.total_amount_input).Text; //Adds to BKM Entry entry = new Entry(){ InOut=inOut, Date = date, Description=description,Type = type, MoneyAccount=moneyAccount, TotalAmount = totalAmount, TaxRate=taxRate}; BKM.addEntry(entry); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Add action bar SupportRequestWindowFeature(WindowCompat.FeatureActionBar); // Set our view from the "activity_view_entry" layout resource SetContentView(Resource.Layout.activity_view_entry); bookKeeperManager = BookKeeperManager.Instance; // Get our views from the layout resource date = FindViewById <TextView>(Resource.Id.view_date_text); description = FindViewById <TextView>(Resource.Id.view_entry_description_text); transactionAccount = FindViewById <TextView>(Resource.Id.view_type_text); moneyAccount = FindViewById <TextView>(Resource.Id.view_to_from_account_text); amount = FindViewById <TextView>(Resource.Id.view_total_with_tax_text); taxRate = FindViewById <TextView>(Resource.Id.view_tax_text); receiptImage = FindViewById <ImageView>(Resource.Id.view_receipt_image); entryId = Intent.GetIntExtra("EntryId", -1); if (entryId != -1) { Entry e = bookKeeperManager.GetEntry(entryId); Account account = bookKeeperManager.GetAccount(e.AccountNumber); Account cashAccount = bookKeeperManager.GetAccount(e.MoneyAccountNumber); TaxRate rate = bookKeeperManager.GetTaxRate(e.TaxId); date.Text = e.Date; description.Text = e.Description; transactionAccount.Text = account.ToString(); moneyAccount.Text = cashAccount.ToString(); amount.Text = e.TotalAmount.ToString(); taxRate.Text = rate.ToString(); if ((e.ImagePath != null) && (e.ImagePath.Length > 0)) { int height = Resources.DisplayMetrics.HeightPixels; int width = receiptImage.Width; Bitmap bitmap = ImageUtils.LoadAndScaleBitmap(e.ImagePath, width, height); receiptImage.SetImageBitmap(bitmap); } } }