package com.cnhct.hechen.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import com.cnhct.hechen.R;
import com.cnhct.hechen.utils.ToastUtil;
import java.util.ArrayList;
import java.util.List;
public class person_regist03_activity extends AppCompatActivity {
private Button bt_next3;
private Button bt_back3;
private Spinner sp_diploma;
private List<String> list;
private ArrayAdapter<String> sp_adapter;
private RadioGroup rg_sex;
private RadioButton female;
private RadioButton male;
String sex="男";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_person_regist03_activity);
//获取下拉框控件
sp_diploma = (Spinner) findViewById(R.id.sp_diploma);
//下拉框数据
list = new ArrayList<String>();
//下拉框适配器list.add("初中及以下");
list.add("高中");
list.add("大专");
list.add("本科");
list.add("硕士及以上");
sp_adapter = new ArrayAdapter<String>(person_regist03_activity.this,
android.R.layout.simple_spinner_item,
list);
sp_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//设置适配器
sp_diploma.setAdapter(sp_adapter);
bt_next3 = (Button) findViewById(R.id.bt_next3);
bt_next3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//获得单选按钮和选择组
rg_sex = (RadioGroup) findViewById(R.id.rg_sex);
female = (RadioButton) findViewById(R.id.female);
male = (RadioButton) findViewById(R.id.male);
//按钮组件设置事件,获得选择的单选按钮内容
// rg_sex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
// @Override
// public void onCheckedChanged(RadioGroup group, int checkedId) {
// if(checkedId==person_regist03_activity.this.female.getId()){
// sex=female.getText().toString();
// ToastUtil.ToastDemo(person_regist03_activity.this,sex);
// }else {
// sex=male.getText().toString();
// ToastUtil.ToastDemo(person_regist03_activity.this,sex);
// }
// }
// });
for (int i = 0;i<rg_sex.getChildCount();i++){
RadioButton radioButton = (RadioButton)rg_sex.getChildAt(i);
if(radioButton.isChecked()){
sex=radioButton.getText().toString();
}
}
Intent intent = new Intent(person_regist03_activity.this,person_regist04_activity.class);
startActivity(intent);
ToastUtil.ToastDemo(person_regist03_activity.this,sex);
}
});
//获取上一步按钮,设置点击事件
bt_back3 = (Button) findViewById(R.id.back3);
bt_back3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(person_regist03_activity.this,person_regist02_activity.class);
startActivity(intent);
}
});
}
}