对上一篇的更新完善
1.基于上一篇,注册页面内容多的话需加一个滚动条使其完全显示:只要用ScrollView把之前的嵌套进去就ok了。
2.对于activity类,只要稍作改动,获取信息,在提示框中就能显示登录者的全部信息(上一篇划线处):
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
nameInput1 = (EditText) this.findViewById(R.id.name);
clickbutton = (Button) this.findViewById(R.id.click);
radioButton1 = (RadioButton) findViewById(R.id.radioButton1);
radioButton2 = (RadioButton) findViewById(R.id.radioButton2);
datePicker1 = (DatePicker) findViewById(R.id.datePicker1);
checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
game = (CheckBox) findViewById(R.id.game);
basketball = (CheckBox) findViewById(R.id.basketball);
clickbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String name = nameInput1.getText().toString();
String sex = "";
if (radioButton1.isChecked()) {
sex = "男";
}
if (radioButton2.isChecked()) {
sex = "女";
}
String date = datePicker1.getYear() + "年"
+ datePicker1.getMonth() + "月"
+ datePicker1.getDayOfMonth() + "日";
String hobby = "";
if (checkBox1.isChecked()) {
hobby = hobby + "," + checkBox1.getText();
}
if (basketball.isChecked()) {
hobby = hobby + "," + basketball.getText();
}
if (game.isChecked()) {
hobby = hobby + "," + game.getText();
}
if (checkBox2.isChecked()) {
hobby = hobby + "," + checkBox2.getText();
}
Toast.makeText(
MainActivity.this,
"注册成功!\n您的姓名:" + name + "\n您的性别是:" + sex + "\n您的生日是:"
+ date + "\n您的爱好:" + hobby, Toast.LENGTH_LONG)
.show();
}
});
}
至此,注册页面算是完全无误的显示了。可能会有简化,到时再做总结。