1、将上一篇的博客内容改为
// startActivity(intent);
startActivityForResult(intent, CODE);
2、在另一个Activity中添加一个按钮
Button button1=(Button)findViewById(R.id.back);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
setResult(0x234);
finish();
}
});
3、在mian_Activity 中添加重写函数
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if((requestCode == CODE)&&(resultCode==CODE)){
((EditText)findViewById(R.id.pwd)).setText("");
((EditText)findViewById(R.id.repwd)).setText("");
}
}