Often there's a scenario where there's a number of UI fields that have to be copied into Model objects. For instance, I'm currently writing a cart page that accepts credit card information in an Activity and I need to write all the inputted values to a CreditCard object.
I end up with blocks of code that look like the following:
CreditCard card = new CreditCard();
card.setFullName(txtFullName.getText().toString());
card.setAddress(txtStreetAddress.getText().toString());
card.setCity(txtCity.getText().toString());
card.setState((String) spinnerState.getSelectedItem());
card.setZip(txtZip.getText().toString());
card.setPhone(txtPhone.getText().toString());
card.setMonth(txtMonth.getText().toString());
card.setYear(txtYear.getText().toString());
card.setNumber(txtNum.getText().toString());
card.setCvv(txtcvv.getText().toString());
I've tried to come up with a way via UI tags in XML or other means to simplify/automate this process but I can't come up with an efficient means. Am I missing out on something?