title: Android Button Losing onClickListener When Keyboard Opens
body: <p>I have a <code>EditText</code> field and a "Save" <code>Button</code> in my Android layout. </p>
  
  <p>When the <code>Fragment</code> is created, I assign an <code>onClickListener</code> to the <code>Button</code>. The <code>Button</code> works correctly before the keyboard opens and after the keyboard closes, but seems to lose its <code>onClickListener</code> while I am editing the <code>EditText</code>.</p>
  
  <p>Is there somewhere I need to reassign the <code>onClickListener</code> so it is available while the keyboard is open?</p>
  
  <p>Here is the layout:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
      android:gravity="top"&gt;
  
      &lt;Button android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="@drawable/add_comment_details"
              android:text="@string/done"
              android:id="@+id/done_button"
              android:textColor="@color/red_1"
  
          android:layout_alignParentBottom="true"
              android:textSize="@dimen/text_size_10"/&gt;
  
      &lt;EditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/text_field2"
          android:layout_above="@id/done_button"
          android:hint="@string/enterText2"
          android:gravity="start"
          android:background="@drawable/add_comment_entertext"
          android:padding="20dp"
      /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here's the code, in a <code>Fragment</code> where I'm adding the <code>onClickListener</code></p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.app_addcommentfragment, null);
  
          text = (EditText) view.findViewById(R.id.text_field2);
          done = (Button) view.findViewById(R.id.done_button);
  
          done.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Log.i("MyFragment","onClick");
                  doneListener.onClick(saveAndClose);
              }
          });
          return view;
      }
  </code></pre>
  
  <p>I am also using <code>android:windowSoftInputMode="adjustResize"</code> in the <code>Manifest</code> so the <code>EditText</code> and the <code>Button</code> both stay on the screen when the keyboard opens.</p>
  
  <p>Some more weirdness, if I switch the layout to this, the button works, but the button takes up most of the screen:</p>
  
  <pre><code>&lt;EditText
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/text_field2"
              android:hint="@string/enterText2"
              android:gravity="start"
              android:background="@drawable/add_comment_entertext"
              android:padding="20dp"
          /&gt;
  &lt;Button android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:background="@drawable/add_comment_details"
                  android:text="@string/done"
                  android:id="@+id/done_button"
                  android:textColor="@color/red_1"                 
                  android:layout_below="@id/text_field2"
                  android:layout_alignParentBottom="true"
                  android:textSize="@dimen/text_size_10"/&gt;
  </code></pre>