public override View GetView(int position, View convertView, ViewGroup parent) { LayoutInflater inflator = (LayoutInflater)this.Context.GetSystemService(Context.LayoutInflaterService); View loanView = inflator.Inflate(Resource.Layout.PersonNameItem, parent, false); TextView personNameField = loanView.FindViewById <TextView>(Resource.Id.personName); TextView balanceText = loanView.FindViewById <TextView>(Resource.Id.personBalance); string personName = this.GetItem(position); personNameField.SetText(personName, TextView.BufferType.Normal); if (this.peopleBalances.ContainsKey(personName)) { int balance = this.peopleBalances[personName]; if (balance == 0) { balanceText.SetText(Resource.String.balanceEven, TextView.BufferType.Normal); balanceText.SetTextColor(Color.Orange); } else { balanceText.SetText( NumberFormatter.FormatBalance(balance), TextView.BufferType.Normal ); balanceText.SetTextColor(balance < 0 ? Color.Red : Color.Green); } } return(loanView); }
public override View GetView(int position, View convertView, ViewGroup parent) { LayoutInflater inflator = (LayoutInflater)this.Context.GetSystemService(Context.LayoutInflaterService); View loanView = inflator.Inflate(Resource.Layout.Loan, parent, false); TextView personName = loanView.FindViewById <TextView>(Resource.Id.loanPersonName); TextView loanAmount = loanView.FindViewById <TextView>(Resource.Id.loanAmountText); TextView loanNotes = loanView.FindViewById <TextView>(Resource.Id.loanNotes); TextView dateAddedText = loanView.FindViewById <TextView>(Resource.Id.dateAddedText); Loan loan = loans[position]; Person person = Repository.GetInstance().GetPersonById(loan.PersonId); personName.SetText(person.Name, TextView.BufferType.Normal); loanNotes.SetText(loan.Notes, TextView.BufferType.Normal); dateAddedText.SetText(loan.DateAdded.ToShortDateString(), TextView.BufferType.Normal); loanAmount.SetText( NumberFormatter.FormatBalance(loan.Amount * (loan.IsOwedToUser ? 1 : -1)), TextView.BufferType.Normal ); loanAmount.SetTextColor(loan.IsOwedToUser ? Color.Green : Color.Red); return(loanView); }
protected void UploadLoanAddInput() { EditText loanInput = FindViewById <EditText>(Resource.Id.loanAddInput); loanInput.SetText(NumberFormatter.FormatBalance(addBalance), TextView.BufferType.Editable); loanInput.SetTextColor(addBalance == 0 ? Color.Orange : (addBalance < 0 ? Color.Red : Color.Green)); }
protected void UpdateLoanCount() { TextView balanceText = FindViewById <TextView>(Resource.Id.balanceText); int balance = Repository.GetInstance().GetTotalAmount(); if (balance == 0) { balanceText.SetText(Resource.String.balanceEven, TextView.BufferType.Normal); balanceText.SetTextColor(Color.Orange); } else { balanceText.SetText( NumberFormatter.FormatBalance(balance), TextView.BufferType.Normal ); balanceText.SetTextColor(balance < 0 ? Color.Red : Color.Green); } }