我有一个开关盒,如果按下signin按钮,它应该移动到下一个Activity。但是,由于某些原因它不起作用。
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button btnAccSignup;
private Button btnSignin;
FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnAccSignup = (Button) findViewById(R.id.btnAccSignup);
btnSignin = (Button) findViewById(R.id.btnSignin);
btnSignin.setOnClickListener(this);
mAuth = FirebaseAuth.getInstance();
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.btnAccSignup:
openSignupActivity(); // This part does not work. Everything else works fine.
break;
case R.id.btnSignin:
userSignin();
break;
}
}
public void openSignupActivity() {
Intent intent = new Intent(MainActivity.this, SignupActivity.class);
startActivity(intent);
}
}
答案 0 :(得分:1)
您忘记添加btnAccSignup
的监听器,您只为btnSignin
添加了监听器。只需添加:
btnAccSignup.setOnClickListener(this);