title: EditText does not show current input (Android 4)
body: <p>My Android application contains an <a href="http://developer.android.com/reference/android/widget/EditText.html" rel="nofollow">EditText</a> view where you can type some short messages (single line). Pressing the keyboard's <em>DONE</em> key will append the message to a log view above (<a href="http://developer.android.com/reference/android/widget/TextView.html" rel="nofollow">TextView</a>) and clear the input view.</p>
  
  <p>Here's a snippet from my view xml:</p>
  
  <pre><code>&lt;LinearLayout ...&gt;
      &lt;TextView
          android:id="@+id/logView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;EditText
          android:id="@+id/inputView"
          android:layout_height="wrap_content"
          android:layout_width="fill_parent"
          android:imeOptions="actionDone"
          android:singleLine="true" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>To handle the input and reset the view, I use the <a href="http://developer.android.com/reference/android/widget/TextView.OnEditorActionListener.html" rel="nofollow">OnEditorActionListener</a>.</p>
  
  <pre><code>@Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
      ...
      String input = mInputView.getText().toString();
      mInputView.setText(""); // clear the input view
      ...
  }
  </code></pre>
  
  <h3>The problem</h3>
  
  <p>I did not experience any problems on Android 1.6 - 3. But starting with IceCreamSandwich (>= Android 4) there's a weird bug which occurs intermittently (in most cases after ~10-30 inputs).</p>
  
  <p>When you type some text, the input view remains blank. The cursor still blinks on position 0, no text is shown. Though a click on <em>DONE</em> adds the (invisible) text to the log view above and the text can be read. Also hiding the keyboard makes the text in the EditText view visible.</p>
  
  <h3>Solution</h3>
  
  <p>As stated in the accepted answer this is a (not so much) known bug of the Android OS. The simple solution is to clear the EditText view in a different way:</p>
  
  <pre><code>TextKeyListener.clear(mInputView.getText());
  </code></pre>