package com.fang.zzti.layout;
import android.app.Application;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import com.fang.zzti.my001.R;
import java.util.ArrayList;
import java.util.List;
public class Questionnaire extends AppCompatActivity
implements RadioGroup.OnCheckedChangeListener,
CompoundButton.OnCheckedChangeListener,
View.OnClickListener{
private RadioGroup rg_gender;
private RadioButton rb_gender1;
private RadioButton rb_gender2;
private RadioGroup rg_department;
private RadioButton rb_department1;
private RadioButton rb_department2;
private RadioButton rb_department3;
private RadioButton rb_department4;
private RadioGroup rg_grade;
private RadioButton rb_grade1;
private RadioButton rb_grade2;
private RadioButton rb_grade3;
private RadioButton rb_grade4;
private RadioGroup rg_consume;
private RadioButton rb_consume1;
private RadioButton rb_consume2;
private RadioButton rb_consume3;
private RadioButton rb_consume4;
private CheckBox cb_meal;
private CheckBox cb_shopping;
private CheckBox cb_study;
private CheckBox cb_amusement;
private CheckBox cb_loveconsume;
private CheckBox cb_internet;
private CheckBox cb_otherconsume;
private EditText et_suggest;
private Button bt_submit;
private Button bt_exit;
private String gender;
private String department;
private String grade;
private String consume;
private ArrayList<String> mainConsume=null;
private String suggestion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_questionnaire);
initView();
}
public void initView(){
// 性别
rg_gender=(RadioGroup)findViewById(R.id.rg_gender);
rb_gender1=(RadioButton)findViewById(R.id.rb_man);
rb_gender2=(RadioButton)findViewById(R.id.rb_woman);
// 学院
rg_department=(RadioGroup)findViewById(R.id.rg_department);
rb_department1=(RadioButton)findViewById(R.id.rb_department1);
rb_department2=(RadioButton)findViewById(R.id.rb_department2);
rb_department3=(RadioButton)findViewById(R.id.rb_department3);
rb_department4=(RadioButton)findViewById(R.id.rb_department4);
//消费
rg_consume=(RadioGroup)findViewById(R.id.rg_consume);
rb_consume1=(RadioButton)findViewById(R.id.rb_consume1);
rb_consume2=(RadioButton)findViewById(R.id.rb_consume2);
rb_consume3=(RadioButton)findViewById(R.id.rb_consume3);
rb_consume4=(RadioButton)findViewById(R.id.rb_consume4);
//年级
rg_grade=(RadioGroup)findViewById(R.id.rg_grade);
rb_grade1=(RadioButton)findViewById(R.id.rb_grade1);
rb_grade2=(RadioButton)findViewById(R.id.rb_grade2);
rb_grade3=(RadioButton)findViewById(R.id.rb_grade3);
rb_grade4=(RadioButton)findViewById(R.id.rb_grade4);
// 主要消费
cb_meal=(CheckBox)findViewById(R.id.cb_mainconsume_a);
cb_shopping=(CheckBox)findViewById(R.id.cb_mainconsume_b);
cb_study=(CheckBox)findViewById(R.id.cb_mainconsume_c);
cb_amusement=(CheckBox)findViewById(R.id.cb_mainconsume_d);
cb_internet=(CheckBox)findViewById(R.id.cb_mainconsume_e);
cb_loveconsume=(CheckBox)findViewById(R.id.cb_mainconsume_f);
cb_otherconsume=(CheckBox)findViewById(R.id.cb_mainconsume_g);
// 建议
et_suggest=(EditText)findViewById(R.id.et_suggest);
bt_submit=(Button)findViewById(R.id.btn_submit);
bt_exit=findViewById(R.id.btn_exit);
bt_submit.setOnClickListener(this);
bt_exit.setOnClickListener(this);
rg_gender.setOnCheckedChangeListener(this);
rg_department.setOnCheckedChangeListener(this);
rg_consume.setOnCheckedChangeListener(this);
rg_grade.setOnCheckedChangeListener(this);
cb_shopping.setOnCheckedChangeListener(this);
cb_meal.setOnCheckedChangeListener(this);
cb_otherconsume.setOnCheckedChangeListener(this);
cb_study.setOnCheckedChangeListener(this);
cb_amusement.setOnCheckedChangeListener(this);
cb_loveconsume.setOnCheckedChangeListener(this);
cb_internet.setOnCheckedChangeListener(this);
mainConsume=new ArrayList<String>();
}
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
switch (checkedId){
case R.id.rb_man:
gender=rb_gender1.getText().toString();
//Toast.makeText(this,"你选择了"+rb_gender1.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_woman:
gender=rb_gender2.getText().toString();
// Toast.makeText(this,"你选择了"+rb_gender2.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_department1:
department=rb_department1.getText().toString();
// Toast.makeText(this,"你选择了"+rb_department1.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_department2:
department=rb_department2.getText().toString();
//Toast.makeText(this,"你选择了"+rb_department2.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_department3:
department=rb_department3.getText().toString();
//Toast.makeText(this,"你选择了"+rb_department3.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_department4:
department=rb_department4.getText().toString();
//Toast.makeText(this,"你选择了"+rb_department4.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_consume1:
consume=rb_consume1.getText().toString();
//Toast.makeText(this,"你选择了"+rb_consume1.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_consume2:
consume=rb_consume2.getText().toString();
//Toast.makeText(this,"你选择了"+rb_consume2.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_consume3:
consume=rb_consume3.getText().toString();
//Toast.makeText(this,"你选择了"+rb_consume3.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_consume4:
consume=rb_consume4.getText().toString();
// Toast.makeText(this,"你选择了"+rb_consume4.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_grade1:
grade=rb_grade1.getText().toString();
// Toast.makeText(this,"你选择了"+rb_grade1.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_grade2:
grade=rb_grade2.getText().toString();
//Toast.makeText(this,"你选择了"+rb_grade2.getText().toString(),Toast.LENGTH_LONG).show();
break;
case R.id.rb_grade3:
grade=rb_grade3.getText().toString();
// Toast.makeText(this,"你选