title: Button working only on second click
body: <p>I have a simple, but annoying problem:</p>
  
  <p>In my fragment, I have a button which should open another activity (intent) on click. However I have to click the button twice, and only the second time it's opening the activity.
  Here is the xml layout of the button:</p>
  
  <pre><code>&lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Go!"
          android:onClick="login"
          android:id="@+id/bt_SignIn"
          android:layout_below="@+id/pass"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="70dp" /&gt;
  </code></pre>
  
  <p>And here is the code for onClick:</p>
  
  <pre><code>public void login(View view){
  bt_SignIn = (Button) findViewById(R.id.bt_SignIn);
       bt_SignIn.setOnClickListener(new View.OnClickListener() {
       @Override
              public void onClick(View view) {
              Intent i = new Intent(getApplicationContext(), Frontpage.class);
                      startActivity(i);
           }
       }
  }
  </code></pre>