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); // 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); } } }
private void SetUpEntryDataForUpdate() { date = DateTime.Today; // Get entry via id and populate fields entry = bookKeeperManager.GetEntry(entryId); entryDescription.Text = entry.Description; dateOfEntry.Text = entry.Date; totalWithTax.Text = entry.TotalAmount.ToString(); Account account = bookKeeperManager.GetAccount(entry.AccountNumber); if (account.Type == Account.AccountType.Expense) { cost_radio.Checked = true; populateTypeSpinner(); typeSpinner.SetSelection(bookKeeperManager.ExpenseAccounts.FindIndex(a => a.Number == account.Number), true); } else if (account.Type == Account.AccountType.Income) { income_radio.Checked = true; populateTypeSpinner(); typeSpinner.SetSelection(bookKeeperManager.MoneyAccounts.FindIndex(a => a.Number == account.Number), true); } PopulateAccountSpinner(); account = bookKeeperManager.GetAccount(entry.MoneyAccountNumber); accountSpinner.SetSelection(bookKeeperManager.MoneyAccounts.FindIndex(a => a.Number == account.Number), true); PopulateTaxSpinner(); TaxRate taxRate = bookKeeperManager.GetTaxRate(entry.TaxId); taxSpinner.SetSelection(bookKeeperManager.TaxRates.FindIndex(a => a.Id == taxRate.Id), true); if (entry.ImagePath != null && entry.ImagePath.Length > 0) { int height = Resources.DisplayMetrics.HeightPixels; int width = receiptImage.Width; Bitmap bitmap = ImageUtils.LoadAndScaleBitmap(entry.ImagePath, width, height); receiptImage.SetImageBitmap(bitmap); } else { imagePathUri = null; } }