public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button1=(Button)findViewById(R.id.confrim); button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub final EditText editAccount=(EditText)findViewById(R.id.edit_Account); final EditText editpwd=(EditText)findViewById(R.id.edit_pwd); final EditText editpwd2=(EditText)findViewById(R.id.edit_pwd2); final RadioButton male=(RadioButton)findViewById(R.id.male); String account=editAccount.getText().toString(); String password; if(editpwd.getText().toString().equals(editpwd2.getText().toString())) { password=editpwd.getText().toString(); } else { AlertDialog.Builder dialog=new AlertDialog.Builder(MainActivity.this); dialog.setTitle("警告"); dialog.setMessage("两次输入密码不一致,请重新输入密码!"); dialog.setPositiveButton("确定", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub editpwd.setText(""); editpwd2.setText(""); editpwd.findFocus(); } }); dialog.show(); password=""; } String gender=male.isChecked()?"男":"女"; Person p=new Person(account,password,gender);
Bundle data=new Bundle();
data.putSerializable("person",p);
Intent intent=new Intent(MainActivity.this,ResultActivity.class);
intent.putExtras(data);
startActivity(intent);
} }); } }
本人初学android,前面代码,我稍微修改了一下,与书中原文略有不同,请教一下,文中说根据用户输入创建了一个Person对象,Person类只是一个简单的DTO对象,该Person类实现了java.io.Serializable接口。因此Person对象是可序列化的。
请教一下,DTO对象是什么,如何声明这个Person类?