title: EditText loses focus when keyboard appears; requires touching twice to edit
body: <p>I have been designing an application which holds an expandable list. At the end of every list, an empty <code>EditText</code> is ready to receive comments. I have the following problem; when I touch the <code>EditText</code>, the screen resizes slightly (not a problem as the resizing does not always happen, depending on my layout and the position of the <code>EditText</code> int he list) and the soft-keyboard appears. However, during these events, the <code>EditText</code> loses focus and does not regain it. This is quite inconvenient as without focus, despite the keyboard being available, the input from the keyboard does not reach the <code>EditText</code>. Once I touch it again, the <code>EditText</code> behaves as expected.</p>
  
  <p>It gets even stranger. With the keyboard still displayed, I can touch a different <code>EditText</code> and the same happens; it loses focus. However, once I passed the initial loss of focus, I can move freely between previously touched <code>EditText</code>s without any focus related issues. Only when I hide the soft-keyboard will the "state" disappear and I would need to tap <code>EditText</code>s twice before being able to edit them.</p>
  
  <p>Here are excerpts from my code. First, the <code>empty_comment.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
  &lt;EditText
      android:id="@+id/blank_box"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:inputType="textCapSentences"
      android:imeOptions="actionDone"
      android:hint="@string/hint"
      android:layout_marginLeft="30dip" &gt;
  &lt;/EditText&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here an excerpt from the fragment where I use the layout in question:</p>
  
  <pre><code>convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_empty, null);
  final EditText editText = (EditText) convertView.findViewById(R.id.blank_box);
  editText.setOnEditorActionListener(new OnEditorActionListener()
  {   
      @Override
      public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
      {
          if(actionId == EditorInfo.IME_ACTION_DONE)
          {
              // Unrelated code
          }
          return true;
      }
  });
  </code></pre>
  
  <p>I am not specifying anything input specific in my manifest file but I could provide it if deemed helpful.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Adding a line to the <code>Activity</code> to adjust the pan <code>android:windowSoftInputMode="adjustPan"</code> does partially solve the problem. It replaces the current unexpected behaviour with the problem that <code>EditText</code> views might get hidden by the soft-keyboard.</p>
  
  <p>As of now, no ideal solution has been found but approached. Have a look at the comments in the accepted answer, they might prove useful to you!</p>