title: looping through List android
body: <p>I have the following method:</p>
  
  <pre><code> public List&lt;String&gt; getAllValue(){
         List&lt;String&gt; list = new ArrayList&lt;String&gt;();
         if(pref.getString(KEY_NUMBER1 , "").length()&gt;2)
             list.add(pref.getString(KEY_NUMBER1 , ""));
         if(pref.getString(KEY_NUMBER2 , "").length()&gt;2)
             list.add(pref.getString(KEY_NUMBER2 , ""));
         if(pref.getString(KEY_NUMBER3 , "").length()&gt;2)
             list.add(pref.getString(KEY_NUMBER3 , ""));
         if(pref.getString(KEY_NUMBER4 , "").length()&gt;2)
             list.add(pref.getString(KEY_NUMBER4 , ""));
         if(pref.getString(KEY_NUMBER5 , "").length()&gt;2)
             list.add(pref.getString(KEY_NUMBER5 , ""));
  
         return list;
     }
  </code></pre>
  
  <p>What I need to do now is to assign these numbers(like <code>KEY_NUMBER1</code>) to the following <code>editTexts</code>:</p>
  
  <pre><code>EditText phoneNumber1, phoneNumber2, phoneNumber3, phoneNumber4, phoneNumber5;
  </code></pre>
  
  <p>Being new to working with Lists, I am having a hard time trying to figure out a way to loop through and assign values to these editTexts, like</p>
  
  <pre><code>phoneNumber1.setText(KEY_NUMBER1);
  phoneNumber2.setText(KEY_NUMBER2);
  phoneNumber3.setText(KEY_NUMBER3);
  </code></pre>