title: How to set text for multiple EditTexts in Android
body: <p>First of all i would like to introduce you with my application, so you have a better point of view what i need. I have database with three tables <code>days</code>, <code>weeks</code>, <code>weekdays</code> and in one Activity i'm fetching all items from days table by selected week, but i don't know how to set text to all members of that class Day. I will show you in following example what i want.</p>
  
  <p>I have achieved setting text to multiple EditTexts, but with many repetition. I want to do this with arrays and loop. I have succeed initializing all EditTexts using array and loop, but i don't know how to implement setting text for all EditTexts.</p>
  
  <p>This is repetition part:</p>
  
  <pre><code>for (int i = 0; i &lt; days.size(); i++) {
          // Monday
          Day day1 = days.get(0);
          etNasteMonday.setText(String.valueOf(day1.getNaste()));
          etInsulinMondayBeforeBreak.setText(String.valueOf(day1.getInsulinBeforeBreak()));
          etDiabetesMondayAfterBreak.setText(String.valueOf(day1.getDiabetesAfterBreak()));
          etDiabetesMondayBeforeLaunch.setText(String.valueOf(day1.getDiabetesBeforeLaunch()));
          etInsulinMondayBeforeLaunch.setText(String.valueOf(day1.getInsulinBeforeLaunch()));
          etDiabetesMondayAfterLaunch.setText(String.valueOf(day1.getDiabetesAfterLaunch()));
          etDiabetesMondayBeforeDinner.setText(String.valueOf(day1.getDiabetesBeforeDinner()));
          etInsulinMondayBeforeDinner.setText(String.valueOf(day1.getInsulinBeforeDinner()));
          etDiabetesMondayAfterDinner.setText(String.valueOf(day1.getDiabetesAfterDinner()));
          etDiabetesMondayBeforeSleep.setText(String.valueOf(day1.getDiabetesBeforeSleep()));
          etInsulinMondayAfterSleep.setText(String.valueOf(day1.getInsulinBeforeSleep()));
          // Tuesday
          Day day2 = days.get(1);
          etNasteUtorak.setText(String.valueOf(day2.getNaste()));
          etInsulinUtorakPreDorucka.setText(String.valueOf(day2.getInsulinBeforeBreak()));
          etDiabetesUtorakPosleDorucka.setText(String.valueOf(day2.getDiabetesAfterBreak()));
          etDiabetesUtorakPreRucka.setText(String.valueOf(day2.getDiabetesBeforeLaunch()));
          etInsulinUtorakPreRucka.setText(String.valueOf(day2.getInsulinBeforeLaunch()));
          etDiabetesUtorakPosleRucka.setText(String.valueOf(day2.getDiabetesAfterLaunch()));
          etDiabetesUtorakPreVecere.setText(String.valueOf(day2.getDiabetesBeforeDinner()));
          etInsulinUtorakPreVecere.setText(String.valueOf(day2.getInsulinBeforeDinner()));
          etDiabetesUtorakPosleVecere.setText(String.valueOf(day2.getDiabetesAfterDinner()));
          etDiabetesUtorakPredSpavanje.setText(String.valueOf(day2.getDiabetesBeforeSleep()));
          etInsulinUtorakPredSpavanje.setText(String.valueOf(day2.getInsulinBeforeSleep()));
      }
  </code></pre>
  
  <p>What should i do to make this more efficient and easier for program to read and how to implement within this code:</p>
  
  <pre><code>List&lt;String&gt; values = new ArrayList&lt;&gt;();
  int[] ids = new int[]{R.id.et_naste_monday, R.id.et_insulin_monday_before_breakf, R.id.et_posle_dorucka_monday, R.id.et_pre_rucka_moday,
      R.id.et_insulin_monday_pre_rucka, R.id.et_posle_rucka_monday, R.id.et_pre_vecere_moday, R.id.et_insulin_monday_pre_vecere, R.id.et_posle_vecere_monday,
      R.id.et_pred_spavanje_moday, R.id.et_insulin_monday_pred_spavanje};
  List&lt;Day&gt; days = mDatabase.getAllDaysByWeek(week.getTitle());
  
  for (int id : ids) {
          EditText t = (EditText) findViewById(id);
          values.add(t.getText().toString());
          t.addTextChangedListener(this);
          applyChangedEditTextColor(false, values, t);
          for (Day day : days) {
              // Here i should do the same part as i done it in above example
          }
      }
  </code></pre>