title: How to set a TextView from an ArrayList, character by character, sequentially?
body: <p>I  want to put a text in a TextView sequentially, with a known time between characters, from a  written text in an EditText</p>
  <p>That is the solution I made:
  I wrote two ArrayList charged from an EditText, the first one with Characters from the EditText , the second one with Integers for determine the time between characters.
  Then I parse the ArrayLists, times load of the time integers are done sequentially, but not the characters, the TextViews are drawn only when the cycle ends.</p>
  <p>My code
  The MainActivity:</p>
  <pre><code>import java.util.ArrayList;
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
  private TextView showCharacter;
  private TextView showAppendCharacter;
  private EditText incomingText;
  private Button readTextEdit;
  
  private ArrayList&lt;CharSequence&gt; toText = new ArrayList&lt;CharSequence&gt;();
  private ArrayList&lt;Integer&gt; timePlay = new ArrayList&lt;Integer&gt;();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      showCharacter = (TextView) findViewById(R.id.showCharacterTextView);
      showAppendCharacter = (TextView) findViewById(R.id.showAppendCharacterTextView);
      incomingText = (EditText) findViewById(R.id.incomingEditText);
      readTextEdit = (Button) findViewById(R.id.readTextButton);
  
      readTextEdit.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              toText.clear();
              timePlay.clear();
              showAppendCharacter.setText(&quot;&quot;);
  
              String text = incomingText.getText().toString();
              for (int base = 0; base &lt; text.length(); base++) {
                  if (String.valueOf(text.charAt(base)).equals(&quot;a&quot;)) {
                      toText.add((&quot;a&quot;));
                      timePlay.add(500);
                  } else if (String.valueOf(text.charAt(base)).equals(&quot;b&quot;)) {
                      toText.add((&quot;b&quot;));
                      timePlay.add(650);
                  } else if (String.valueOf(text.charAt(base)).equals(&quot;c&quot;)) {
                      toText.add((&quot;c&quot;));
                      timePlay.add(800);
                  } else {
                      toText.add((&quot;_&quot;));
                      timePlay.add(1000);
                  }
              }
  
              for (int pos = 0; pos &lt; toText.size(); pos++) {
                  try {
                      Thread.sleep(timePlay.get(pos));
                      showCharacter.setText((String) toText.get(pos));
                      showAppendCharacter.append((String) toText.get(pos));
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }
      });
  }
  }
  </code></pre>
  <p>The activity_main.xml</p>
  <pre><code>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:id=&quot;@+id/LinearLayout1&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  android:orientation=&quot;vertical&quot;
  tools:context=&quot;.MainActivity&quot; &gt;
  
  &lt;TextView
      android:id=&quot;@+id/showCharacterTextView&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:text=&quot;@string/showCharacterTextView&quot;
      android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;
  
  &lt;TextView
      android:id=&quot;@+id/showAppendCharacterTextView&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:text=&quot;@string/showAppendCharactersTextView&quot;
      android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;
  
  &lt;EditText
      android:id=&quot;@+id/incomingEditText&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:ems=&quot;10&quot;
      android:hint=&quot;@string/incomingTextEditText&quot;
      android:inputType=&quot;text&quot; &gt;
  
      &lt;requestFocus /&gt;
  &lt;/EditText&gt;
  
  &lt;Button
      android:id=&quot;@+id/readTextButton&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:text=&quot;@string/readButton&quot; /&gt;
  </code></pre>
  
  <p>The strings.xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  </code></pre>
  
  <pre><code>&lt;string name=&quot;app_name&quot;&gt;texto Desde ArrayList&lt;/string&gt;
  &lt;string name=&quot;action_settings&quot;&gt;Settings&lt;/string&gt;
  &lt;string name=&quot;showCharacterTextView&quot;&gt;Show last Character&lt;/string&gt;
  &lt;string name=&quot;showAppendCharactersTextView&quot;&gt;Show append Characters&lt;/string&gt;
  &lt;string name=&quot;incomingTextEditText&quot;&gt;Incoming text&lt;/string&gt;
  &lt;string name=&quot;readButton&quot;&gt;Read text&lt;/string&gt;
  </code></pre>