我有2个活动和2个文件.xml,在nameActivity中有buttonCancel和buttonNewUser,在SignUpActivity中有buttonBack,当我点击buttonNewUser时它执行SignUpActivity,当我点击buttonBack它回到nameActivity但是当我点击buttonCancel时它是回到 SignUpActivity,就像在绕圈子走一样。
nameActivity 中的代码如下:
Button signUp, cancel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_name);
signUp = (Button)findViewById(R.id.buttonNewUser);
signUp.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),SignUpActivity.class);
startActivityForResult(intent, 0);
}
});
cancel = (Button)findViewById(R.id.buttonCancel);
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
System.exit(0);
}
});
}
SignUpActivity 中的代码:
按钮返回;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
back = (Button)findViewById(R.id.btnBackSignUp);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),NameActivity.class);
startActivityForResult(intent, 0);
}
});
}
为什么,怎么了?