I have my main Activity with two Buttons on it. When I start the application, you can click on one Button and it will take you to the right Activity, but I can click the second Button a hundred times and nothing happens. It looks just like the first Button and changes to the usual blue color when I press it, BUT if I go the the first button's Activity, then go BACK to the first Activity, the second Button works. I don’t understand what’s going on here.
Main Activity:(Note, SignUp is the button that doesn’t work):
public class GameNetActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.first);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Button SignIn = (Button) findViewById(R.id.button1);
SignIn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Welcome.class);
startActivityForResult(myIntent, 0);
Button SignUp = (Button) findViewById(R.id.button2);
SignUp.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Signup.class);
startActivityForResult(myIntent, 0);
}
});
}
});
}
}
You have registered for the onClickListener for SignUp button within the onClickListener of SignIn button. Take that out and put it separately in the onCreate().
Hope this helps!!