I have a simple, but annoying problem:
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:
<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" />
And here is the code for onClick:
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);
}
}
}