0
我有2個活動和2個文件.xml,在nameActivity中有buttonCancel和buttonNewUser,在SignUpActivity中有buttonBack,當我點擊buttonNewUser時它執行SignUpActivity,當我點擊buttonBack時,它返回nameActivity,但是當我點擊buttonCancel時,它返回到了SignUpActivity,就像走在圓圈裏。我的android按鈕不起作用
守則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);
}
});
}
爲什麼,怎麼了?
好的..是的,這是工作。謝謝 – 2013-02-18 18:33:23